-
-
Notifications
You must be signed in to change notification settings - Fork 23
83 lines (73 loc) · 2.27 KB
/
release.yaml
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
name: Release
on:
push:
tags: ["*"]
jobs:
# Create a GitHub release
release:
name: Create a GitHub release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout the repository
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Setup Python and Git
uses: ./.github/actions/setup-python-and-git
with:
python-version: '3.11'
- name: Parse changelog
shell: bash
run: |
function extract_version_content() {
changelog=$1
target_version=$2
awk -v target="$target_version" '
/^## / {
if (found) exit;
version=$2;
if (version == target) found=1;
next;
}
found { print; }
' <<< "$changelog"
}
changelog=$(cat "CHANGELOG.md")
target_version=${GITHUB_REF#refs/tags/}
echo "TAG_NAME=$target_version" >> $GITHUB_ENV
content=$(extract_version_content "$changelog" "$target_version")
if [ -n "$content" ]; then
echo "::notice::Found release notes for ${target_version}"
echo "$content" >> release-notes.md
else
echo "::warning::Did not find release notes for ${target_version}"
touch release-notes.md
fi
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist
if-no-files-found: warn
- name: Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
tag_name: "${{ env.TAG_NAME }}"
body_path: release-notes.md
# Upload to real PyPI on GitHub Releases.
release-pypi:
name: Publish released package to pypi.org
runs-on: ubuntu-latest
needs: build-package
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}