11name : Release
22
3- # Runs when you push a version tag: git tag v99.0.12 && git push origin v99.0.12
43on :
54 push :
5+ branches :
6+ - main
67 tags :
78 - ' v*'
9+ workflow_dispatch :
10+
11+ concurrency :
12+ group : release-${{ github.ref }}
13+ cancel-in-progress : true
814
915permissions :
1016 contents : write # needed to create the GitHub Release
@@ -25,31 +31,76 @@ jobs:
2531 node-version : ' 24'
2632 cache : ' npm'
2733
34+ - name : Cache VS Code test runtime
35+ uses : actions/cache@v4
36+ with :
37+ path : .vscode-test
38+ key : vscode-test-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
39+ restore-keys : |
40+ vscode-test-${{ runner.os }}-
41+
2842 - name : Install dependencies
2943 run : npm ci
3044
45+ - name : Build and typecheck
46+ run : npm run pretest
47+
48+ - name : Run tests
49+ run : npm test
50+
3151 # vsce package auto-calls vscode:prepublish (esbuild minify) before packing
3252 - name : Build & package VSIX
33- env :
34- RELEASE_TAG : ${{ github.ref_name }}
35- run : npm run package:vsix
53+ run : |
54+ if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
55+ RELEASE_TAG="${GITHUB_REF_NAME}" npm run package:vsix
56+ else
57+ npm run package:vsix
58+ fi
59+
60+ - name : Upload VSIX artifact
61+ uses : actions/upload-artifact@v4
62+ with :
63+ name : copilot-cockpit-vsix
64+ path : archive/vsix/latest/copilot-cockpit-*.vsix
3665
3766 # Generate release notes from CHANGELOG.md when present, otherwise write fallback notes
38- - name : Extract changelog section
39- run : node ./scripts/release-notes.js CHANGELOG.md release-notes.md
67+ - name : Generate release metadata
68+ shell : bash
69+ run : |
70+ if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
71+ echo "RELEASE_TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
72+ echo "RELEASE_TITLE=Copilot Cockpit ${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
73+ echo "RELEASE_PRERELEASE=false" >> "$GITHUB_ENV"
74+ node ./scripts/release-notes.js CHANGELOG.md release-notes.md
75+ else
76+ echo "RELEASE_TAG=edge" >> "$GITHUB_ENV"
77+ echo "RELEASE_TITLE=Copilot Cockpit edge" >> "$GITHUB_ENV"
78+ echo "RELEASE_PRERELEASE=true" >> "$GITHUB_ENV"
79+ {
80+ echo "Automated prerelease from main."
81+ echo
82+ echo "- Commit: ${GITHUB_SHA}"
83+ echo "- Source ref: ${GITHUB_REF_NAME}"
84+ echo "- Trigger: push"
85+ echo "- Packaged from workspace version: $(node -p \"require('./package.json').version\")"
86+ } > release-notes.md
87+ fi
4088
4189 - name : Create or update GitHub Release with VSIX
4290 env :
4391 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
92+ shell : bash
4493 run : |
45- if gh release view "${{ github.ref_name }}" >/dev/null 2>&1; then
46- gh release upload "${{ github.ref_name }}" archive/vsix/latest/copilot-cockpit-*.vsix --clobber
47- gh release edit "${{ github.ref_name }}" \
48- --title "Copilot Cockpit ${{ github.ref_name }}" \
49- --notes-file release-notes.md
94+ if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
95+ gh release upload "${RELEASE_TAG}" archive/vsix/latest/copilot-cockpit-*.vsix --clobber
96+ gh release edit "${RELEASE_TAG}" \
97+ --title "${RELEASE_TITLE}" \
98+ --notes-file release-notes.md \
99+ $([[ "${RELEASE_PRERELEASE}" == "true" ]] && echo --prerelease || echo --latest)
50100 else
51- gh release create "${{ github.ref_name } }" \
101+ gh release create "${RELEASE_TAG }" \
52102 archive/vsix/latest/copilot-cockpit-*.vsix \
53- --title "Copilot Cockpit ${{ github.ref_name }}" \
54- --notes-file release-notes.md
103+ --title "${RELEASE_TITLE}" \
104+ --notes-file release-notes.md \
105+ $([[ "${RELEASE_PRERELEASE}" == "true" ]] && echo --prerelease)
55106 fi
0 commit comments