Skip to content

Commit 60c7d12

Browse files
author
Michael Gasperini
committed
ci: verify release assets by digest before publishing
1 parent 18d2a01 commit 60c7d12

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ jobs:
7979
id-token: write
8080

8181
steps:
82-
- name: Download the released VSIX
82+
- name: Validate release tag
83+
env:
84+
RELEASE_TAG: ${{ inputs.tag }}
85+
run: |
86+
set -euo pipefail
87+
[[ "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]
88+
89+
- name: Download and verify the released VSIX
8390
env:
8491
GH_TOKEN: ${{ github.token }}
8592
RELEASE_TAG: ${{ inputs.tag }}
@@ -90,9 +97,15 @@ jobs:
9097
gh release download "$RELEASE_TAG" \
9198
--repo "$GITHUB_REPOSITORY" \
9299
--pattern "$VSIX" \
93-
--pattern "$VSIX.sha256" \
94100
--dir .release
95-
(cd .release && sha256sum -c "$VSIX.sha256")
101+
gh release view "$RELEASE_TAG" \
102+
--repo "$GITHUB_REPOSITORY" \
103+
--json assets > release-assets.json
104+
expected="$(jq -r --arg name "$VSIX" '.assets[] | select(.name == $name) | .digest' release-assets.json)"
105+
test -n "$expected"
106+
test "$expected" != "null"
107+
actual="sha256:$(sha256sum ".release/$VSIX" | awk '{print $1}')"
108+
test "$actual" = "$expected"
96109
97110
- name: Publish to Visual Studio Marketplace
98111
env:

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@ the GitHub release exists, dispatch the `Release` workflow with that release tag
117117
gh workflow run release.yml -f tag=v<x.y.z>
118118
```
119119

120-
The publish job downloads the released VSIX, verifies its checksum, and publishes it to both registries
121-
with short-lived OIDC credentials. No registry publisher token is stored in the repository, local
122-
automation, or GitHub Actions secrets.
120+
The publish job downloads the released VSIX, verifies its SHA-256 against the digest recorded on the
121+
GitHub release asset, and publishes it to both registries with short-lived OIDC credentials. No
122+
registry publisher token is stored in the repository, local automation, or GitHub Actions secrets.

0 commit comments

Comments
 (0)