-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (69 loc) · 2.62 KB
/
Copy pathrelease.yml
File metadata and controls
79 lines (69 loc) · 2.62 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
name: Auto-release
on:
workflow_run:
workflows: ["Test"]
branches: [master]
types:
- completed
workflow_dispatch:
jobs:
new-release:
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
outputs:
version_changed: ${{ steps.version-check.outputs.version_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to get all tags for version comparison
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.*"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Check if version changed
id: version-check
run: |
# Get current version from pyproject.toml
CURRENT_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Check if this version already has a tag
if git tag --list | grep -q "^v$CURRENT_VERSION$"; then
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version v$CURRENT_VERSION already exists as a tag"
else
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "New version v$CURRENT_VERSION detected - will create release"
fi
- name: Create GitHub Release
if: steps.version-check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version-check.outputs.current_version }}
name: Release v${{ steps.version-check.outputs.current_version }}
draft: false
prerelease: false
generate_release_notes: true
- name: Create Sentry release
uses: getsentry/action-release@v3
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
# Trigger PyPI workflow when after we create a release.
# Pypi workflow won't with the usual on-release trigger
# because another workflow (this one) created the release. (avoiding inf recursion)
- name: Trigger PyPI workflow
if: steps.version-check.outputs.version_changed == 'true'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: new-release-created
client-payload: '{"version": "${{ steps.version-check.outputs.current_version }}"}'