-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (61 loc) · 2.1 KB
/
auto-release.yml
File metadata and controls
68 lines (61 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Auto-release following a release commit
on:
push:
branches:
- main
- master
paths:
- 'docs/CHANGELOG.md'
jobs:
release:
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.parse_commit.outputs.RELEASE_VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Parse commit message to get version
id: parse_commit
run: |
# Commit message must be in the format of
# "chore: release vX.X"
VERSION=$(echo "$COMMIT_MESSAGE" | grep -oP '^chore:\ release\ v[a-zA-Z0-9.\-\+]+' | head -n 1 | cut -d' ' -f3)
if [[ -z "$VERSION" ]]; then
echo "Commit message does not match the expected format. Please use 'chore: release vX.X.X' format in your commit message."
echo "Commit message: $COMMIT_MESSAGE"
exit 1
fi
echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_OUTPUT"
env:
# Avoid script injection by using an environment variable
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
- name: Parse CHANGELOG.md to get release notes
id: parse_changelog
uses: kiyoon/parse-changelog-action@v1
with:
changelog-file-path: docs/CHANGELOG.md
version: ${{ steps.parse_commit.outputs.RELEASE_VERSION }}
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.parse_commit.outputs.RELEASE_VERSION }}
name: ${{ steps.parse_commit.outputs.RELEASE_VERSION }}
body: ${{ steps.parse_changelog.outputs.body }}
publish-to-pypi:
needs: release
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.RELEASE_VERSION }}
fetch-depth: 0 # full history
fetch-tags: true
- uses: deargen/workflows/actions/setup-python-and-uv@master
- name: Build and upload to PyPI
run: |
uv build
uv publish