Repository navigation
106 lines (100 loc) · 3.55 KB
/
Copy pathrelease.yml
File metadata and controls
106 lines (100 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
name: Release
# Pushing a tag v<version> (the version in pyproject.toml) publishes that
# version to PyPI, through trusted publishing: no token is stored here, and
# the publish action attests each file (PEP 740), so PyPI shows which commit
# and workflow built it. Then a GitHub release for the tag carries the
# files, their CycloneDX SBOM and the CHANGELOG's notes.
on:
push:
tags: ["v*"]
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Test and build
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
- name: The tag matches the package's version
env:
TAG: ${{ github.ref_name }}
run: |
version=$(uv version --short)
if [ "$TAG" != "v$version" ]; then
echo "tag $TAG doesn't match the version in pyproject.toml ($version)" >&2
exit 1
fi
- run: uv sync --locked
- run: uv run --locked --python 3.11 --isolated pytest -q
- run: uv run --locked --python 3.14 --isolated pytest -q
- run: uv build
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
if-no-files-found: error
# Kept out of dist/, which is exactly what goes to PyPI.
- name: SBOM and release notes
run: |
version=$(uv version --short)
if ! grep -q "^## $version (" CHANGELOG.md; then
echo "CHANGELOG.md has no entry for $version (## $version (<date>))" >&2
exit 1
fi
mkdir -p release
# The runtime dependencies, as locked and tested here.
uv export --format cyclonedx1.5 --preview-features sbom-export --frozen --no-dev \
-o "release/wakeshift-$version.cdx.json"
awk -v v="$version" '
$0 ~ "^## " { if (on) exit; if (index($0, "## " v " (") == 1) { on = 1; next } }
on { print }
' CHANGELOG.md >release/notes.md
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release
path: release/
if-no-files-found: error
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: pypi
url: https://pypi.org/project/wakeshift/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
release:
name: GitHub release, with the SBOM
needs: publish
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release
path: release/
- name: Release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag \
--title "$TAG" --notes-file release/notes.md dist/* release/*.cdx.json