-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.59 KB
/
Copy pathrelease.yml
File metadata and controls
53 lines (46 loc) · 1.59 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
name: Release
on:
push:
branches: [main]
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# pyproject.toml is the single source of truth for the version:
# c64lib.__version__ is read from the installed metadata (derived from
# pyproject), the CHANGELOG heading is test-locked to it, and this
# workflow tags/releases exactly that version. A commit that bumps
# pyproject IS the release; any other push is a no-op.
- name: Read version from pyproject.toml
id: version
run: |
version=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
echo "tag=v$version" >> "$GITHUB_OUTPUT"
if git rev-parse -q --verify "refs/tags/v$version" >/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-python@v5
if: steps.version.outputs.exists == 'false'
with:
python-version: "3.12"
- name: Build packages
if: steps.version.outputs.exists == 'false'
run: |
python -m pip install --quiet build
python -m build
- name: Create release
if: steps.version.outputs.exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: >
gh release create "${{ steps.version.outputs.tag }}"
--target "$GITHUB_SHA"
--generate-notes
dist/*