Repository navigation
130 lines (117 loc) · 5.44 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (117 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Release
on:
push:
tags: ["v*"]
# Re-publish an existing tag, e.g. to send it to the Chrome Web Store after a failed or skipped upload.
workflow_dispatch:
inputs:
tag:
description: "Existing tag, e.g. v2.0.0"
required: true
permissions:
contents: write
jobs:
check:
uses: ./.github/workflows/check.yml
with:
ref: ${{ inputs.tag || github.ref_name }}
release:
needs: check
runs-on: ubuntu-latest
env:
CWS_REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
EDGE_API_KEY: ${{ secrets.EDGE_API_KEY }}
TAG: ${{ inputs.tag || github.ref_name }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ env.TAG }}
- name: Check tag matches manifest version
run: |
version=$(python3 -c 'import json; print(json.load(open("extension/manifest.json"))["version"])')
test "v$version" = "$TAG" || { echo "tag $TAG != manifest v$version"; exit 1; }
- run: python3 scripts/build_release.py
- name: GitHub Release
id: gh_release
env:
GH_TOKEN: ${{ github.token }}
# A re-run for a tag that already has its release only does the store upload.
run: gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" release/moondigest-*-chrome.zip --title "MoonDigest $TAG" --generate-notes
# Skipped when the OAuth secrets are missing. Upload also submits for review.
- name: Chrome Web Store
if: env.CWS_REFRESH_TOKEN != ''
env:
EXTENSION_ID: bnjihpbocpimaipifanfkjjpfdbigggd
PUBLISHER_ID: 4f572405-456e-41da-8d5d-6f86651e94b0
CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
REFRESH_TOKEN: ${{ env.CWS_REFRESH_TOKEN }}
run: npx --yes chrome-webstore-upload-cli@4 --source release/moondigest-*-chrome.zip
# Runs even if the Chrome upload failed. Upload, then submit with certification notes.
- name: Edge Add-ons
if: ${{ !cancelled() && steps.gh_release.outcome == 'success' && env.EDGE_API_KEY != '' }}
env:
PRODUCT_ID: 6fc379b9-a130-466f-86c6-a52f5596bbd3
CLIENT_ID: ${{ secrets.EDGE_CLIENT_ID }}
NOTES: >-
Open a bilibili.com or youtube.com video page to read its subtitles. AI summaries in the side panel
use an API key the user adds in the options page. bilibili subtitles and the favorites and follow
organizers need a bilibili.com login.
Changes: https://github.com/PathGao/MoonDigest/releases/tag/${{ env.TAG }}
run: |
api="https://api.addons.microsoftedge.microsoft.com/v1/products/$PRODUCT_ID/submissions"
auth=(-H "Authorization: ApiKey $EDGE_API_KEY" -H "X-ClientID: $CLIENT_ID")
# POST, take the operation id from the Location header, poll until it leaves InProgress.
run_op() {
local code loc status
code=$(curl -sS -D headers -o body -w '%{http_code}' "${auth[@]}" "$@")
[ "$code" = 202 ] || { echo "HTTP $code"; cat body; return 1; }
loc=$(tr -d '\r' < headers | awk 'tolower($1)=="location:"{print $2}')
for _ in $(seq 60); do
sleep 5
body=$(curl -sS "${auth[@]}" "$poll/${loc##*/}")
status=$(jq -r .status <<<"$body")
[ "$status" = InProgress ] || break
done
echo "$body"
[ "$status" = Succeeded ]
}
poll="$api/draft/package/operations"
run_op -X POST -H "Content-Type: application/zip" --data-binary @"$(ls release/moondigest-*-chrome.zip)" "$api/draft/package"
poll="$api/operations"
run_op -X POST -H "Content-Type: application/json" -d "$(jq -n --arg notes "$NOTES" '{notes: $notes}')" "$api"
# The MCP server (mcp/) goes to npm when its package.json version is not there yet, so a release that did not touch
# it publishes nothing. No token: npm trusts this workflow (the package's Trusted Publisher setting names
# PathGao/MoonDigest and release.yml). The first version is published by hand, since that setting needs the package
# to exist; until then this job only says so.
npm:
needs: check
# Not on a re-run for an old tag: that would publish the tag's old code as a new version.
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.tag || github.ref_name }}
- uses: actions/setup-node@v5
with:
node-version: 24
registry-url: https://registry.npmjs.org
# Trusted publishing needs npm 11.5.1 or newer.
- run: npm install -g npm@latest
- name: Publish moondigest-mcp
working-directory: mcp
run: |
version=$(node -p "require('./package.json').version")
# Only a 404 means the package is not there; any other failure (the registry down) fails the job.
if ! out=$(npm view moondigest-mcp versions --json 2>&1); then
if echo "$out" | grep -q E404; then echo "moondigest-mcp is not on npm yet: publish the first version by hand (docs/RELEASE.md)"; exit 0; fi
echo "$out"; exit 1
fi
if echo "$out" | grep -q "\"$version\""; then echo "moondigest-mcp@$version is already on npm"; exit 0; fi
npm ci
npm test
npm publish --access public