@@ -2,51 +2,212 @@ name: Release
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ version_bump_type :
7+ description : " Version bump type (patch, minor, major)"
8+ required : true
9+ default : " patch"
10+ type : choice
11+ options :
12+ - patch
13+ - minor
14+ - major
15+
16+ permissions :
17+ contents : write # To push version bump commit/tag, create release, upload assets
18+ pull-requests : read # Potentially needed for future release note generation
519
620jobs :
7- submit-chrome :
21+ # 1. Prepare Release: Bump version, commit, tag, push
22+ prepare_release :
823 runs-on : ubuntu-latest
24+ outputs :
25+ new_version : ${{ steps.version_bump.outputs.new_version }}
26+ tag_name : ${{ steps.version_bump.outputs.tag_name }}
927 steps :
10- - uses : actions/checkout@v4
28+ - name : Checkout full history
29+ uses : actions/checkout@v4
30+ with :
31+ fetch-depth : 0
32+ # token: ${{ secrets.YOUR_PAT_IF_NEEDED }} # Use PAT if needed to trigger other workflows
1133
12- - uses : pnpm/action-setup@v4
34+ - name : Setup pnpm
35+ uses : pnpm/action-setup@v4
1336
14- - uses : actions/setup-node@v4
37+ - name : Setup Node.js (Use LTS version)
38+ uses : actions/setup-node@v4
1539 with :
16- node-version : 23
40+ node-version : 20 # Recommend using LTS version
1741 cache : " pnpm"
1842
1943 - name : Install dependencies
2044 run : pnpm install
2145
22- - name : Zip Chrome extension
23- run : pnpm zip
46+ - name : Configure Git User
47+ run : |
48+ git config user.name "github-actions[bot]"
49+ git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+ - name : Configure npm tag prefix (optional, ensures tags like v1.0.0)
52+ run : npm config set tag-version-prefix v
53+
54+ - name : Bump version, Create Tag, and Commit
55+ id : version_bump
56+ run : |
57+ # Bump version using pnpm
58+ pnpm version ${{ inputs.version_bump_type }} --no-git-tag-version # Commit/tag manually
59+
60+ # Extract the new version and create tag name
61+ NEW_VERSION=$(node -p "require('./package.json').version")
62+ TAG_NAME="v${NEW_VERSION}"
63+
64+ echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_OUTPUT
65+ echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_OUTPUT
66+
67+ # Stage changes, commit, and tag
68+ git add package.json pnpm-lock.yaml # Add files changed by pnpm version
69+ git commit -m "chore: release ${TAG_NAME}"
70+ git tag ${TAG_NAME}
71+
72+ - name : Push Changes and Tag
73+ run : |
74+ git push origin HEAD # Push the commit
75+ git push origin ${{ steps.version_bump.outputs.tag_name }} # Push the tag
76+
77+ # 2. Build and Submit Chrome Extension
78+ build_submit_chrome :
79+ needs : prepare_release
80+ runs-on : ubuntu-latest
81+ outputs :
82+ chrome_zip_name : ${{ steps.get_paths.outputs.chrome_zip_name }}
83+ chrome_zip_path : ${{ steps.get_paths.outputs.chrome_zip_path }}
84+ steps :
85+ - name : Checkout specific tag
86+ uses : actions/checkout@v4
87+ with :
88+ ref : ${{ needs.prepare_release.outputs.tag_name }}
89+
90+ - name : Setup pnpm
91+ uses : pnpm/action-setup@v4
92+
93+ - name : Setup Node.js
94+ uses : actions/setup-node@v4
95+ with :
96+ node-version : 20
97+ cache : " pnpm"
98+
99+ - name : Install dependencies
100+ run : pnpm install
101+
102+ - name : Build and Zip Chrome extension
103+ run : pnpm zip # Assumes this creates the zip in .output/
104+
105+ - name : Determine Chrome Zip Path
106+ id : get_paths
107+ run : |
108+ CHROME_ZIP=$(ls .output/*-chrome.zip | head -n 1)
109+ echo "chrome_zip_name=$(basename $CHROME_ZIP)" >> $GITHUB_OUTPUT
110+ echo "chrome_zip_path=$CHROME_ZIP" >> $GITHUB_OUTPUT
111+ echo "Found Chrome Zip: $CHROME_ZIP"
24112
25113 - name : Submit to Chrome Web Store
26- run : pnpm exec dotenvx run -- pnpm wxt submit --chrome-zip .output/*-chrome.zip
114+ run : pnpm exec dotenvx run -- pnpm wxt submit --chrome-zip ${{ steps.get_paths.outputs.chrome_zip_path }}
27115 env :
28- DOTENV_PRIVATE_KEY : ${{ secrets.DOTENV_PRIVATE_KEY }}
116+ DOTENV_PRIVATE_KEY : ${{ secrets.DOTENV_PRIVATE_KEY }} # Ensure this secret is configured
29117
30- submit-firefox :
118+ - name : Upload Chrome Zip Artifact
119+ uses : actions/upload-artifact@v4
120+ with :
121+ name : chrome-extension
122+ path : ${{ steps.get_paths.outputs.chrome_zip_path }}
123+ if-no-files-found : error
124+
125+ # 3. Build and Submit Firefox Extension
126+ build_submit_firefox :
127+ needs : prepare_release
31128 runs-on : ubuntu-latest
129+ outputs :
130+ firefox_zip_name : ${{ steps.get_paths.outputs.firefox_zip_name }}
131+ firefox_zip_path : ${{ steps.get_paths.outputs.firefox_zip_path }}
32132 steps :
33- - uses : actions/checkout@v4
133+ - name : Checkout specific tag
134+ uses : actions/checkout@v4
135+ with :
136+ ref : ${{ needs.prepare_release.outputs.tag_name }}
34137
35- - uses : pnpm/action-setup@v4
138+ - name : Setup pnpm
139+ uses : pnpm/action-setup@v4
36140
37- - uses : actions/setup-node@v4
141+ - name : Setup Node.js
142+ uses : actions/setup-node@v4
38143 with :
39- node-version : 23
144+ node-version : 20
40145 cache : " pnpm"
41146
42147 - name : Install dependencies
43148 run : pnpm install
44149
45- - name : Zip Firefox extension
150+ - name : Build and Zip Firefox extension
46151 run : pnpm zip:firefox
47152
153+ - name : Determine Firefox Zip Path
154+ id : get_paths
155+ run : |
156+ # Find only the main firefox zip file
157+ FIREFOX_ZIP=$(ls .output/*-firefox.zip | head -n 1)
158+ echo "firefox_zip_name=$(basename $FIREFOX_ZIP)" >> $GITHUB_OUTPUT
159+ echo "firefox_zip_path=$FIREFOX_ZIP" >> $GITHUB_OUTPUT
160+ echo "Found Firefox Zip: $FIREFOX_ZIP"
161+
48162 - name : Submit to Firefox Add-ons
49163 run : |
50- pnpm exec dotenvx run -- pnpm wxt submit --firefox-zip .output/*-firefox.zip --firefox-sources-zip .output/*-sources.zip
164+ # Submit only the main zip; wxt handles sources if needed
165+ pnpm exec dotenvx run -- pnpm wxt submit --firefox-zip ${{ steps.get_paths.outputs.firefox_zip_path }}
166+ env :
167+ DOTENV_PRIVATE_KEY : ${{ secrets.DOTENV_PRIVATE_KEY }} # Ensure this secret is configured
168+
169+ - name : Upload Firefox Zip Artifact
170+ uses : actions/upload-artifact@v4
171+ with :
172+ name : firefox-extension
173+ path : ${{ steps.get_paths.outputs.firefox_zip_path }}
174+ if-no-files-found : error
175+
176+ # 4. Create GitHub Release and Upload Assets
177+ create_github_release :
178+ needs : [prepare_release, build_submit_chrome, build_submit_firefox]
179+ runs-on : ubuntu-latest
180+ permissions :
181+ contents : write # To create release and upload assets
182+ steps :
183+ - name : Download Chrome artifact
184+ uses : actions/download-artifact@v4
185+ with :
186+ name : chrome-extension
187+ path : ./release-assets/chrome
188+
189+ - name : Download Firefox artifact
190+ uses : actions/download-artifact@v4
191+ with :
192+ name : firefox-extension
193+ path : ./release-assets/firefox
194+
195+ - name : List downloaded files (for debugging)
196+ run : ls -R ./release-assets
197+
198+ - name : Create GitHub Release
199+ uses : softprops/action-gh-release@v2
200+ with :
201+ tag_name : ${{ needs.prepare_release.outputs.tag_name }}
202+ name : Release ${{ needs.prepare_release.outputs.tag_name }}
203+ body : |
204+ Release version ${{ needs.prepare_release.outputs.new_version }}
205+
206+ **Assets:**
207+ - Chrome Extension (`${{ needs.build_submit_chrome.outputs.chrome_zip_name }}`)
208+ - Firefox Extension (`${{ needs.build_submit_firefox.outputs.firefox_zip_name }}`)
209+ files : |
210+ ./release-assets/chrome/*
211+ ./release-assets/firefox/*
51212 env :
52- DOTENV_PRIVATE_KEY : ${{ secrets.DOTENV_PRIVATE_KEY }}
213+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments