-
-
Notifications
You must be signed in to change notification settings - Fork 437
111 lines (95 loc) · 3.55 KB
/
Copy pathrelease.yml
File metadata and controls
111 lines (95 loc) · 3.55 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
104
105
106
107
108
109
110
111
name: Release
on:
push:
branches: [main]
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.extract.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from pyproject.toml
id: extract
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Check if tag exists
id: check
run: |
VERSION="${{ steps.extract.outputs.version }}"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists"
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "Tag v$VERSION does not exist"
echo "should_release=true" >> $GITHUB_OUTPUT
fi
release:
needs: check-version
if: needs.check-version.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # For trusted PyPI publishing
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install
- name: Extract changelog for version
id: changelog
run: |
VERSION="${{ needs.check-version.outputs.version }}"
echo "Extracting changelog for version $VERSION"
# Extract the changelog section for this version using sed
sed -n "/^## \\[$VERSION\\]/,/^## \\[/{/^## \\[$VERSION\\]/d; /^## \\[/q; /^$/d; p}" CHANGELOG.md > release_notes.md
# If no changelog found, create a simple message
if [ ! -s release_notes.md ]; then
echo "No specific changelog found for version $VERSION" > release_notes.md
fi
echo "Release notes:"
cat release_notes.md
- name: Create git tag
run: |
VERSION="${{ needs.check-version.outputs.version }}"
git config user.name "maciekdymarczyk"
git config user.email "maciek@roboblog.eu"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check-version.outputs.version }}
name: Release v${{ needs.check-version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: false
- name: Build package
run: |
uv build
ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
notify-success:
needs: [check-version, release]
if: needs.check-version.outputs.should_release == 'true' && success()
runs-on: ubuntu-latest
steps:
- name: Success notification
run: |
echo "🎉 Successfully released v${{ needs.check-version.outputs.version }}!"
echo "- GitHub Release: https://github.com/${{ github.repository }}/releases/tag/v${{ needs.check-version.outputs.version }}"
echo "- PyPI: https://pypi.org/project/claude-monitor/${{ needs.check-version.outputs.version }}/"