|
1 | 1 | name: Release VS Code extension |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: ["vscode-v*"] |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + candidate_sha: |
| 7 | + description: Exact 40-character branch-head commit SHA to release |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + dry_run: |
| 11 | + description: Validate full CI and VSIX artifacts without tagging or publishing |
| 12 | + required: false |
| 13 | + default: false |
| 14 | + type: boolean |
6 | 15 |
|
7 | | -# Never cancelled and never coalesced: every publish runs to completion. |
8 | 16 | concurrency: |
9 | 17 | group: ${{ github.workflow }}-${{ github.run_id }} |
10 | 18 | cancel-in-progress: false |
11 | 19 |
|
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + actions: read |
| 23 | + |
12 | 24 | jobs: |
13 | 25 | full-coverage: |
14 | 26 | runs-on: ubuntu-24.04 |
15 | | - permissions: |
16 | | - actions: read |
17 | | - contents: read |
18 | 27 | steps: |
19 | 28 | - uses: actions/checkout@v4 |
20 | | - - name: Require exact-SHA full release CI before publication |
| 29 | + with: |
| 30 | + ref: ${{ inputs.candidate_sha }} |
| 31 | + - name: Require exact-SHA full release CI before tagging |
21 | 32 | env: |
22 | 33 | GH_TOKEN: ${{ github.token }} |
23 | | - run: python ci/verify_full_coverage.py --sha "$GITHUB_SHA" |
| 34 | + EXPECTED_SHA: ${{ inputs.candidate_sha }} |
| 35 | + run: | |
| 36 | + [[ "$EXPECTED_SHA" =~ ^[0-9a-f]{40}$ ]] |
| 37 | + [[ "$GITHUB_REF" == refs/heads/* ]] |
| 38 | + test "$EXPECTED_SHA" = "$GITHUB_SHA" |
| 39 | + test "$(git rev-parse HEAD)" = "$EXPECTED_SHA" |
| 40 | + python ci/verify_full_coverage.py --sha "$EXPECTED_SHA" |
24 | 41 |
|
25 | | - validate-tag: |
| 42 | + validate-version: |
| 43 | + needs: [full-coverage] |
26 | 44 | runs-on: ubuntu-24.04 |
27 | 45 | outputs: |
28 | 46 | version: ${{ steps.version.outputs.version }} |
| 47 | + tag: ${{ steps.version.outputs.tag }} |
29 | 48 | steps: |
30 | 49 | - uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + ref: ${{ inputs.candidate_sha }} |
31 | 52 | - id: version |
| 53 | + env: |
| 54 | + EXPECTED_SHA: ${{ inputs.candidate_sha }} |
32 | 55 | run: | |
| 56 | + test "$(git rev-parse HEAD)" = "$EXPECTED_SHA" |
33 | 57 | VERSION=$(node -p "require('./vscode-plugin/package.json').version") |
34 | | - test "${GITHUB_REF_NAME}" = "vscode-v${VERSION}" |
| 58 | + TAG="vscode-v${VERSION}" |
| 59 | + if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then |
| 60 | + git fetch --no-tags origin "refs/tags/${TAG}:refs/tags/${TAG}" |
| 61 | + test "$(git rev-parse "${TAG}^{commit}")" = "$EXPECTED_SHA" || { |
| 62 | + echo "Existing tag ${TAG} points to another commit" >&2 |
| 63 | + exit 1 |
| 64 | + } |
| 65 | + fi |
35 | 66 | echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 67 | + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
| 68 | +
|
36 | 69 | build: |
37 | | - needs: [validate-tag, full-coverage] |
38 | | - if: needs.full-coverage.result == 'success' |
| 70 | + needs: [full-coverage, validate-version] |
| 71 | + if: needs.full-coverage.result == 'success' && needs.validate-version.result == 'success' |
39 | 72 | uses: ./.github/workflows/vscode-extension.yml |
40 | 73 | with: |
41 | 74 | release_build: true |
| 75 | + |
| 76 | + artifact-preflight: |
| 77 | + needs: [full-coverage, validate-version, build] |
| 78 | + if: needs.full-coverage.result == 'success' && needs.validate-version.result == 'success' && needs.build.result == 'success' |
| 79 | + runs-on: ubuntu-24.04 |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + ref: ${{ inputs.candidate_sha }} |
| 84 | + - uses: actions/download-artifact@v4 |
| 85 | + with: { pattern: vscode-*, path: artifacts, merge-multiple: true } |
| 86 | + - name: Validate the seven VSIX packages before tagging |
| 87 | + env: |
| 88 | + VERSION: ${{ needs.validate-version.outputs.version }} |
| 89 | + EXPECTED_SHA: ${{ inputs.candidate_sha }} |
| 90 | + run: | |
| 91 | + test "$(git rev-parse HEAD)" = "$EXPECTED_SHA" |
| 92 | + python ci/vscode_release_artifact_lint.py --artifacts artifacts --version "$VERSION" |
| 93 | +
|
| 94 | + create-tag: |
| 95 | + needs: [full-coverage, validate-version, artifact-preflight] |
| 96 | + if: >- |
| 97 | + !cancelled() && |
| 98 | + inputs.dry_run != true && |
| 99 | + needs.full-coverage.result == 'success' && |
| 100 | + needs.validate-version.result == 'success' && |
| 101 | + needs.artifact-preflight.result == 'success' |
| 102 | + runs-on: ubuntu-24.04 |
| 103 | + permissions: |
| 104 | + contents: write |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + with: |
| 108 | + ref: ${{ inputs.candidate_sha }} |
| 109 | + - name: Create release tag from the verified commit |
| 110 | + env: |
| 111 | + EXPECTED_SHA: ${{ inputs.candidate_sha }} |
| 112 | + TAG: ${{ needs.validate-version.outputs.tag }} |
| 113 | + run: | |
| 114 | + test "$(git rev-parse HEAD)" = "$EXPECTED_SHA" |
| 115 | + git config --local user.email "action@github.com" |
| 116 | + git config --local user.name "GitHub Action" |
| 117 | + if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then |
| 118 | + git fetch --no-tags origin "refs/tags/${TAG}:refs/tags/${TAG}" |
| 119 | + test "$(git rev-parse "${TAG}^{commit}")" = "$EXPECTED_SHA" || { |
| 120 | + echo "Existing tag ${TAG} points to another commit" >&2 |
| 121 | + exit 1 |
| 122 | + } |
| 123 | + else |
| 124 | + git tag -a "$TAG" -m "Release VS Code ${{ needs.validate-version.outputs.version }}" |
| 125 | + git push origin "refs/tags/${TAG}" |
| 126 | + fi |
| 127 | +
|
42 | 128 | publish: |
43 | | - needs: [validate-tag, full-coverage, build] |
44 | | - if: needs.full-coverage.result == 'success' && needs.build.result == 'success' |
| 129 | + needs: [full-coverage, validate-version, artifact-preflight, create-tag] |
| 130 | + if: >- |
| 131 | + !cancelled() && |
| 132 | + inputs.dry_run != true && |
| 133 | + needs.full-coverage.result == 'success' && |
| 134 | + needs.artifact-preflight.result == 'success' && |
| 135 | + needs.create-tag.result == 'success' |
45 | 136 | runs-on: ubuntu-24.04 |
46 | 137 | permissions: |
47 | 138 | contents: write |
48 | 139 | id-token: write |
49 | 140 | attestations: write |
50 | 141 | steps: |
| 142 | + - uses: actions/checkout@v4 |
| 143 | + with: |
| 144 | + ref: ${{ inputs.candidate_sha }} |
51 | 145 | - uses: actions/download-artifact@v4 |
52 | | - with: { path: artifacts, merge-multiple: true } |
| 146 | + with: { pattern: vscode-*, path: artifacts, merge-multiple: true } |
| 147 | + - name: Verify release artifacts again |
| 148 | + env: |
| 149 | + VERSION: ${{ needs.validate-version.outputs.version }} |
| 150 | + EXPECTED_SHA: ${{ inputs.candidate_sha }} |
| 151 | + run: | |
| 152 | + test "$(git rev-parse HEAD)" = "$EXPECTED_SHA" |
| 153 | + python ci/vscode_release_artifact_lint.py --artifacts artifacts --version "$VERSION" |
53 | 154 | - name: Produce checksums |
54 | 155 | run: | |
55 | 156 | cd artifacts |
|
60 | 161 | - name: Create GitHub release from the verified package bytes |
61 | 162 | env: |
62 | 163 | GH_TOKEN: ${{ github.token }} |
63 | | - run: gh release create "$GITHUB_REF_NAME" artifacts/* --title "FastLED VS Code ${{ needs.validate-tag.outputs.version }}" --generate-notes |
| 164 | + TAG: ${{ needs.validate-version.outputs.tag }} |
| 165 | + VERSION: ${{ needs.validate-version.outputs.version }} |
| 166 | + run: gh release create "$TAG" artifacts/* --title "FastLED VS Code $VERSION" --generate-notes |
64 | 167 | - name: Publish those same prebuilt VSIX files to Marketplace |
65 | 168 | env: |
66 | 169 | VSCE_PAT: ${{ secrets.VSCE_PAT }} |
|
0 commit comments