Skip to content

Commit a83ee72

Browse files
committed
ci(workflows): add draft workflow for automatic release publishing
1 parent 3ce2606 commit a83ee72

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Continuous Delivery
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: ${{ github.workflow }}-release-${{ github.ref_name }}
16+
cancel-in-progress: false
17+
18+
permissions:
19+
contents: write
20+
21+
steps:
22+
- name: Setup | Checkout Repository on Release Branch
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.ref_name }}
26+
fetch-depth: 0
27+
28+
- name: Setup | Force release branch to be at workflow sha
29+
run: |
30+
git reset --hard ${{ github.sha }}
31+
32+
- name: Evaluate | Verify upstream has NOT changed
33+
shell: bash
34+
run: |
35+
set +o pipefail
36+
37+
UPSTREAM_BRANCH_NAME="$(git status -sb | head -n 1 | awk -F '\\.\\.\\.' '{print $2}' | cut -d ' ' -f1)"
38+
printf '%s\n' "Upstream branch name: $UPSTREAM_BRANCH_NAME"
39+
40+
set -o pipefail
41+
42+
if [ -z "$UPSTREAM_BRANCH_NAME" ]; then
43+
printf >&2 '%s\n' "::error::Unable to determine upstream branch name!"
44+
exit 1
45+
fi
46+
47+
git fetch "${UPSTREAM_BRANCH_NAME%%/*}"
48+
49+
if ! UPSTREAM_SHA="$(git rev-parse "$UPSTREAM_BRANCH_NAME")"; then
50+
printf >&2 '%s\n' "::error::Unable to determine upstream branch sha!"
51+
exit 1
52+
fi
53+
54+
HEAD_SHA="$(git rev-parse HEAD)"
55+
56+
if [ "$HEAD_SHA" != "$UPSTREAM_SHA" ]; then
57+
printf >&2 '%s\n' "[HEAD SHA] $HEAD_SHA != $UPSTREAM_SHA [UPSTREAM SHA]"
58+
printf >&2 '%s\n' "::error::Upstream has changed, aborting release..."
59+
exit 1
60+
fi
61+
62+
printf '%s\n' "Verified upstream branch has not changed, continuing with release..."
63+
64+
- name: Action | Semantic Version Release
65+
id: release
66+
uses: python-semantic-release/python-semantic-release@v10.4.1
67+
with:
68+
github_token: ${{ secrets.GITHUB_TOKEN }}
69+
git_committer_name: "github-actions"
70+
git_committer_email: "actions@users.noreply.github.com"
71+
72+
- name: Publish | Upload to GitHub Release Assets
73+
uses: python-semantic-release/publish-action@v10.4.1
74+
if: steps.release.outputs.released == 'true'
75+
with:
76+
github_token: ${{ secrets.GITHUB_TOKEN }}
77+
tag: ${{ steps.release.outputs.tag }}
78+
79+
- name: Upload | Distribution Artifacts
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: distribution-artifacts
83+
path: dist
84+
if-no-files-found: error

0 commit comments

Comments
 (0)