Skip to content

Commit 786309f

Browse files
committed
ci: improve workflow
- Support `EXTENSION_NAME_SUFFIX`, `FIREFOX_EXTENSION_ID`, and `FIREFOX_EXTENSION_CHANNEL` environment variables. - Skip changelog checking and Git tag generating for non-production environment.
1 parent 33e4a8d commit 786309f

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

.github/workflows/publish.yml

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,20 @@ jobs:
3939
TIMEZONE: ${{ vars.TIMEZONE || 'UTC' }}
4040
run: |
4141
VERSION=$(jq -r '.version' './src/manifest.chromium.json')
42-
VERSION_FX=$(jq -r '.version' './src/manifest.firefox.json')
43-
if [ "$VERSION" != "$VERSION_FX" ]; then
44-
echo "❌ Mismatching manifest versions"
45-
exit 1
46-
fi
47-
48-
EXPECTED_LINE="## [$VERSION] - $(TZ="$TIMEZONE" date +%Y-%m-%d)"
49-
if ! grep -Fxq "$EXPECTED_LINE" CHANGELOG.md; then
50-
echo "❌ Missing expected changelog line: $EXPECTED_LINE"
51-
exit 1
42+
for file in src/manifest*.json; do
43+
VERSION2=$(jq -r '.version' "$file")
44+
if [ "$VERSION" != "$VERSION2" ]; then
45+
echo "❌ Mismatching manifest version: '$file'"
46+
exit 1
47+
fi
48+
done
49+
50+
if [ '${{ github.event.inputs.environment }}' = 'production' ]; then
51+
EXPECTED_LINE="## [$VERSION] - $(TZ="$TIMEZONE" date +%Y-%m-%d)"
52+
if ! grep -Fxq "$EXPECTED_LINE" CHANGELOG.md; then
53+
echo "❌ Missing expected changelog line: $EXPECTED_LINE"
54+
exit 1
55+
fi
5256
fi
5357
5458
echo "version=$VERSION" >> $GITHUB_OUTPUT
@@ -59,6 +63,24 @@ jobs:
5963
echo "artifact_zip=webscrapbook-zip" >> $GITHUB_OUTPUT
6064
echo "artifact_xpi=webscrapbook-xpi" >> $GITHUB_OUTPUT
6165
66+
- name: Set extension name suffix
67+
if: vars.EXTENSION_NAME_SUFFIX != ''
68+
run: |
69+
for file in src/_locales/*/messages.json; do
70+
echo "Updating '$file'..."
71+
jq '.ExtensionName.message += "${{ vars.EXTENSION_NAME_SUFFIX }}"' "$file" > .tmp.json
72+
mv .tmp.json "$file"
73+
done
74+
75+
- name: Set Firefox extension ID
76+
if: vars.FIREFOX_EXTENSION_ID != ''
77+
run: |
78+
for file in src/manifest.firefox*.json; do
79+
echo "Updating '$file'..."
80+
jq '.browser_specific_settings.gecko.id = "${{ vars.FIREFOX_EXTENSION_ID }}"' "$file" > .tmp.json
81+
mv .tmp.json "$file"
82+
done
83+
6284
- name: Set up Node.js
6385
uses: actions/setup-node@v4
6486
with:
@@ -74,6 +96,7 @@ jobs:
7496
run: npm run pack
7597

7698
- name: Create Git tag
99+
if: github.event.inputs.environment == 'production'
77100
run: |
78101
git tag --force ${{ steps.config.outputs.tag_name }}
79102
git push origin ${{ steps.config.outputs.tag_name }}
@@ -149,7 +172,10 @@ jobs:
149172
uses: kewisch/action-web-ext@v1
150173
with:
151174
cmd: sign
152-
channel: listed
175+
176+
# 'listed' or 'unlisted'
177+
channel: ${{ vars.FIREFOX_EXTENSION_CHANNEL }}
178+
153179
source: ${{ needs.main.outputs.ext_path_xpi }}
154180
artifacts: dist
155181
apiKey: ${{ secrets.FIREFOX_API_KEY }}

0 commit comments

Comments
 (0)