Skip to content

Commit 7a3fb2b

Browse files
committed
Harden release recovery
1 parent 96e6003 commit 7a3fb2b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ on:
99
tag:
1010
description: Existing release tag to publish
1111
required: true
12-
type: string
12+
type: choice
13+
options:
14+
- v0.1.0
1315

1416
permissions:
1517
contents: read
@@ -34,9 +36,16 @@ jobs:
3436
run: |
3537
git fetch --no-tags origin main:refs/remotes/origin/main
3638
release_sha=$(git rev-parse HEAD)
37-
tag_sha=$(git rev-parse "$RELEASE_TAG^{commit}")
39+
tag_object=$(git rev-parse --verify "refs/tags/${RELEASE_TAG}")
40+
tag_sha=$(git rev-parse --verify "refs/tags/${RELEASE_TAG}^{commit}")
3841
test "$release_sha" = "$tag_sha"
3942
git merge-base --is-ancestor "$release_sha" origin/main
43+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
44+
test "$GITHUB_REF" = "refs/heads/main"
45+
test "$RELEASE_TAG" = "v0.1.0"
46+
test "$tag_object" = "1bac90e875b7373fe391f7fbe359783ef545a522"
47+
test "$release_sha" = "82f510c3a40aa576bfeef277dd406d42b788250b"
48+
fi
4049
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
4150
with:
4251
python-version: "3.12"
@@ -185,6 +194,9 @@ jobs:
185194
with:
186195
persist-credentials: false
187196
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }}
197+
- name: Verify recovery source
198+
if: github.event_name == 'workflow_dispatch'
199+
run: test "$(git rev-parse HEAD)" = "82f510c3a40aa576bfeef277dd406d42b788250b"
188200
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
189201
with:
190202
python-version: "3.12"

0 commit comments

Comments
 (0)