Skip to content

Commit f1332e4

Browse files
committed
ci(release-wkflow): harden flaws & improve release job definition
1 parent 658f7d6 commit f1332e4

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,30 @@ jobs:
3434

3535
release:
3636
name: Semantic Release
37+
concurrency: release
3738
runs-on: ubuntu-latest
38-
concurrency: push
39-
needs: [build]
39+
if: github.repository == 'python-semantic-release/publish-action'
40+
needs:
41+
- validate
4042

4143
permissions:
42-
id-token: write
4344
contents: write
4445

4546
steps:
46-
- uses: actions/checkout@v4
47+
# Note: we need to checkout the repository at the workflow sha in case during the workflow
48+
# the branch was updated. To keep PSR working with the configured release branches,
49+
# we force a checkout of the desired release branch but at the workflow sha HEAD.
50+
- name: Setup | Checkout Repository at workflow sha
51+
uses: actions/checkout@v4
4752
with:
4853
fetch-depth: 0
49-
ref: ${{ github.ref_name }}
54+
ref: ${{ github.sha }}
5055

51-
- name: Python Semantic Release
56+
- name: Setup | Force correct release branch on workflow sha
57+
run: |
58+
git checkout -B ${{ github.ref_name }}
59+
60+
- name: Release | Python Semantic Release
5261
id: release
5362
uses: python-semantic-release/[email protected]
5463
with:
@@ -58,7 +67,7 @@ jobs:
5867
prerelease: ${{ github.event.inputs.as-prerelease }}
5968
changelog: false
6069

61-
- name: Update Minor Release Tag Reference
70+
- name: Release | Update Minor Release Tag Reference
6271
if: steps.release.outputs.released == 'true' && steps.release.outputs.is_prerelease == 'false'
6372
env:
6473
FULL_VERSION_TAG: ${{ steps.release.outputs.tag }}
@@ -67,7 +76,7 @@ jobs:
6776
git tag --force --annotate "$MINOR_VERSION_TAG" "${FULL_VERSION_TAG}^{}" -m "$MINOR_VERSION_TAG"
6877
git push origin "$MINOR_VERSION_TAG" --force
6978
70-
- name: Update Major Release Tag Reference
79+
- name: Release | Update Major Release Tag Reference
7180
if: steps.release.outputs.released == 'true' && steps.release.outputs.is_prerelease == 'false'
7281
env:
7382
FULL_VERSION_TAG: ${{ steps.release.outputs.tag }}

0 commit comments

Comments
 (0)