1- name : build-and-publish-zip
2-
1+ name : build-and-release
32on :
43 push :
54 branches : [ main ]
87permissions :
98 contents : write
109
10+ concurrency :
11+ group : build-and-release-${{ github.ref }}
12+ cancel-in-progress : true
13+
1114jobs :
12- build :
15+ release :
1316 runs-on : ubuntu-latest
1417 steps :
15- - name : Checkout
16- uses : actions/checkout@v4
18+ - uses : actions/checkout@v4
1719
18- - name : Setup Node
19- uses : actions/setup-node@v4
20+ - uses : actions/setup-node@v4
2021 with :
2122 node-version : ' 20'
2223 cache : ' npm'
@@ -27,47 +28,35 @@ jobs:
2728 - name : Build
2829 run : npm run build
2930
30- - name : Install tools
31- run : |
32- sudo apt-get update
33- sudo apt-get install -y jq zip
34-
35- - name : Resolve version
31+ - name : Resolve version (Node only)
3632 id : ver
3733 shell : bash
3834 run : |
39- if [ -f dist/manifest.json ]; then
40- ver=$(jq -r '.version' dist/manifest.json)
41- elif [ -f manifest.json ]; then
42- ver=$(jq -r '.version' manifest.json)
43- else
44- ver=$(jq -r '.version' package.json)
45- fi
46- echo "version=$ver" >> "$GITHUB_OUTPUT"
35+ VERSION=$(node - <<'NODE'
36+ const fs = require('fs');
37+ const read = p => { try { return JSON.parse(fs.readFileSync(p, 'utf8')).version } catch { return null } };
38+ process.stdout.write(read('dist/manifest.json') || read('manifest.json') || read('package.json') || '0.0.0');
39+ NODE
40+ )
41+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4742
4843 - name : Zip dist
44+ shell : bash
4945 run : |
5046 mkdir -p artifacts
51- cd dist
52- zip -r "../artifacts/extension-v${{ steps.ver.outputs.version }}.zip" .
53- cd -
54-
55- - name : Copy to vulnerable-web/downloads
56- run : |
57- mkdir -p vulnerable-web/downloads
58- cp "artifacts/extension-v${{ steps.ver.outputs.version }}.zip" vulnerable-web/downloads/
59- cp "artifacts/extension-v${{ steps.ver.outputs.version }}.zip" vulnerable-web/downloads/latest.zip
60-
61- - name : Commit zip into repo
62- run : |
63- git config user.name "github-actions[bot]"
64- git config user.email "github-actions[bot]@users.noreply.github.com"
65- git add vulnerable-web/downloads/*
66- git commit -m "chore: publish extension zip v${{ steps.ver.outputs.version }} [skip ci]" || echo "No changes"
67- git push
47+ (cd dist && zip -r "../artifacts/extension-v${{ steps.ver.outputs.version }}.zip" .)
48+ cp "artifacts/extension-v${{ steps.ver.outputs.version }}.zip" "artifacts/extension.zip"
6849
69- - name : Upload artifact (optional)
70- uses : actions/upload-artifact@v4
50+ - name : Create GitHub Release and upload assets
51+ uses : softprops/action-gh-release@v2
7152 with :
72- name : extension-v${{ steps.ver.outputs.version }}
73- path : artifacts/*.zip
53+ tag_name : v${{ steps.ver.outputs.version }}
54+ name : v${{ steps.ver.outputs.version }}
55+ draft : false
56+ prerelease : false
57+ generate_release_notes : true
58+ files : |
59+ artifacts/extension-v${{ steps.ver.outputs.version }}.zip
60+ artifacts/extension.zip
61+ env :
62+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments