-
-
Notifications
You must be signed in to change notification settings - Fork 23
93 lines (83 loc) · 2.49 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
84
85
86
87
88
89
90
91
92
93
name: Release
on:
push:
tags: ["*"]
workflow_dispatch:
inputs:
tag_name:
description: The name of the tag to release
type: string
required: true
jobs:
# Package when a new tag is pushed
# build-package:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# token: ${{ secrets.PAT }}
#
# - name: Package
# uses: hynek/build-and-inspect-python-package@v1
# Create a GitHub release
release:
name: Create a GitHub release
runs-on: ubuntu-latest
needs: build-package
steps:
- uses: actions/checkout@v3
- 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
- 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
if: startsWith(github.ref, 'refs/tags/')
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 }}