Skip to content

Commit 0a3d534

Browse files
refactor: Address feedback on release workflow
1 parent 461d7ec commit 0a3d534

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

.github/scripts/update-manifest.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
// Get the tag from the environment variable GitHub Actions provides
5+
const tag = process.env.GITHUB_REF_NAME;
6+
if (!tag) {
7+
console.error("Error: GITHUB_REF_NAME environment variable not set.");
8+
process.exit(1);
9+
}
10+
11+
// The version is the tag name without the 'v' prefix
12+
const version = tag.substring(1);
13+
14+
// Path to the manifest file
15+
const manifestPath = path.resolve(__dirname, '../../frontend/manifest.json');
16+
17+
// Read, update, and write the manifest file
18+
try {
19+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
20+
manifest.version = version;
21+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
22+
console.log(`Successfully updated ${manifestPath} to version ${version}`);
23+
} catch (error) {
24+
console.error(`Error updating manifest file: ${error.message}`);
25+
process.exit(1);
26+
}

.github/workflows/release.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
- name: Checkout code
2020
uses: actions/checkout@v4
2121
with:
22+
# Full history is required for the release notes generator
2223
fetch-depth: 0
2324

2425
- name: Setup Node.js
@@ -31,17 +32,17 @@ jobs:
3132
working-directory: ./frontend
3233

3334
- name: Update manifest.json version
34-
run: |
35-
node -e "let manifest = require('./frontend/manifest.json'); manifest.version = '${{ github.ref_name }}'.substring(1); require('fs').writeFileSync('./frontend/manifest.json', JSON.stringify(manifest, null, 2));"
36-
echo "frontend/manifest.json updated to version ${{ github.ref_name }}"
35+
run: node .github/scripts/update-manifest.js
3736

3837
- name: Commit and Update Tag
3938
run: |
4039
git config --global user.name 'github-actions[bot]'
4140
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
4241
git add frontend/manifest.json
43-
git commit -m "chore: Bump frontend version to ${{ github.ref_name }}"
4442
# This command updates the tag to point to the new commit
43+
git commit -m "chore: Bump frontend version to ${{ github.ref_name }}"
44+
# Force push is required to move the tag to the new commit,
45+
# which includes the manifest.json version bump.
4546
git push origin --force ${{ github.ref_name }}
4647
4748
- name: Build frontend extension

0 commit comments

Comments
 (0)