Repository navigation
109 lines (102 loc) · 3.1 KB
/
Copy pathrelease.yml
File metadata and controls
109 lines (102 loc) · 3.1 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
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check the tag against the package version
if: startsWith(github.ref, 'refs/tags/v')
run: |
version=$(python3 -c 'import re, pathlib; print(re.search(r"__version__ = \"([^\"]+)\"", pathlib.Path("src/nnnotes/__init__.py").read_text()).group(1))')
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "tag $GITHUB_REF_NAME and package $version differ" >&2
exit 1
fi
if ! grep -qF "## [$version]" CHANGELOG.md; then
echo "CHANGELOG.md has no section for $version" >&2
exit 1
fi
quality:
needs: check
uses: ./.github/workflows/ci.yml
# the sdist and one pure Python wheel; the wheel is tested with the deck model the extra pins
build:
needs: [check, quality]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.13"
- name: Build and check the distributions
run: |
python -m pip install --upgrade pip build twine
python -m build --outdir dist
python -m twine check --strict dist/*
ls dist
- name: Test the installed wheel
run: python .github/scripts/smoke_wheel.py dist
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error
pypi:
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/nnnotes/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
# trusted publishing: PyPI accepts this workflow's OIDC token, no API token is stored
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
github-release:
needs: pypi
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Release notes
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --latest --strip header
env:
OUTPUT: RELEASE_NOTES.md
GITHUB_REPO: ${{ github.repository }}
- name: Use reviewed release notes when available
run: |
reviewed="release-notes/${GITHUB_REF_NAME}.txt"
if [ -f "$reviewed" ]; then
cp "$reviewed" RELEASE_NOTES.md
fi
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: GitHub release
uses: softprops/action-gh-release@v3
with:
body_path: RELEASE_NOTES.md
files: |
dist/*.tar.gz
dist/*.whl