-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (86 loc) · 2.83 KB
/
release.yml
File metadata and controls
103 lines (86 loc) · 2.83 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image for release
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: python-template:release
cache-from: type=gha
- name: Run full test suite
run: |
docker run --rm python-template:release uv run make check
docker run --rm python-template:release uv run make test
- name: Generate changelog
id: changelog
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
if git describe --tags --abbrev=0 HEAD^ >/dev/null 2>&1; then
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^)
echo "## Changes since $PREVIOUS_TAG" > CHANGELOG.md
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD >> CHANGELOG.md
else
echo "## Initial Release" > CHANGELOG.md
git log --pretty=format:"- %s (%h)" >> CHANGELOG.md
fi
{
echo 'changelog<<EOF'
cat CHANGELOG.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog.outputs.tag_name }}
release_name: Release ${{ steps.changelog.outputs.tag_name }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: ${{ contains(steps.changelog.outputs.tag_name, '-') }}
- name: Build and export release artifacts
run: |
mkdir -p dist
docker run --rm -v $(pwd)/dist:/dist python-template:release sh -c "
uv export --no-hashes --no-dev > /dist/requirements.txt
uv export --no-hashes > /dist/requirements-dev.txt
"
docker run --rm -v $(pwd)/dist:/dist python-template:release sh -c "
uv build --wheel --sdist --out-dir /dist
"
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts-${{ steps.changelog.outputs.tag_name }}
path: dist/
notify:
runs-on: ubuntu-latest
needs: release
if: always()
steps:
- name: Notify on success
if: needs.release.result == 'success'
run: |
echo "✅ Release ${{ needs.release.outputs.tag_name }} created successfully!"
- name: Notify on failure
if: needs.release.result == 'failure'
run: |
echo "❌ Release creation failed!"
exit 1