-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.79 KB
/
release.yml
File metadata and controls
88 lines (74 loc) · 2.79 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
name: GitHub Release
on:
push:
branches:
- main
jobs:
release:
name: Create GitHub release (on version bump)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect pyproject version bump
id: detect
shell: bash
run: |
set -euo pipefail
if ! git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -q '^pyproject\.toml$'; then
echo "pyproject.toml did not change; skipping release."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
new_version="$(awk -F'"' '/^version\s*=\s*"/ {print $2; exit}' pyproject.toml)"
before="${{ github.event.before }}"
if [[ "$before" == "0000000000000000000000000000000000000000" ]]; then
old_version=""
else
old_version="$(git show "${before}:pyproject.toml" | awk -F'"' '/^version\s*=\s*"/ {print $2; exit}' || true)"
fi
if [[ -z "$new_version" ]]; then
echo "Could not parse version from pyproject.toml"
exit 1
fi
echo "Old version: ${old_version:-<none>}"
echo "New version: ${new_version}"
if [[ "$new_version" == "$old_version" ]]; then
echo "Version did not change; skipping release."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "version=${new_version}" >> "$GITHUB_OUTPUT"
echo "tag=v${new_version}" >> "$GITHUB_OUTPUT"
- name: Skip if tag already exists
id: tagexists
if: steps.detect.outputs.changed == 'true'
shell: bash
run: |
set -euo pipefail
tag="${{ steps.detect.outputs.tag }}"
if git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
echo "Tag ${tag} already exists; skipping release."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Install uv
if: steps.detect.outputs.changed == 'true' && steps.tagexists.outputs.skip != 'true'
uses: astral-sh/setup-uv@v4
- name: Build sdist and wheel
if: steps.detect.outputs.changed == 'true' && steps.tagexists.outputs.skip != 'true'
run: uv build
- name: Create GitHub release
if: steps.detect.outputs.changed == 'true' && steps.tagexists.outputs.skip != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.detect.outputs.tag }}
target_commitish: ${{ github.sha }}
generate_release_notes: true
files: |
dist/*