-
-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (69 loc) · 2.08 KB
/
release.yml
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
name: Publish
on:
push:
tags:
- v*
workflow_dispatch: # allows you to trigger manually
permissions:
contents: write
attestations: write
id-token: write
jobs:
release-notes:
name: Create Release Notes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate Changelog
run: |-
echo "Release Notes" > ${{ github.workflow }}-CHANGELOG.rst
echo "-------------" >> ${{ github.workflow }}-CHANGELOG.rst
PAT="^---"
L1=$(grep -n $PAT HISTORY.rst | sed -n 1p | cut -d ":" -f 1)
L2=$(grep -n $PAT HISTORY.rst | sed -n 2p | cut -d ":" -f 1)
awk "NR > $L1 && NR < $L2 - 1" HISTORY.rst >> ${{ github.workflow }}-CHANGELOG.rst
- name: Convert rst to md
uses: docker://pandoc/core
with:
args: >-
${{ github.workflow }}-CHANGELOG.rst
--wrap=none
-t markdown
-o ${{ github.workflow }}-CHANGELOG.md
- name: Remove extra spaces
run: |-
sed -i 's/- /- /g' ${{ github.workflow }}-CHANGELOG.md
- name: Github Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: ${{ github.workflow }}-CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-package:
name: Build and Inspect Python Package
runs-on: ubuntu-latest
needs: release-notes
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
with:
attest-build-provenance-github: true
release-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build-package
steps:
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Generate artifact attestation for sdist and wheel
uses: actions/attest-build-provenance@v1
with:
subject-path: dist
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1