-
Notifications
You must be signed in to change notification settings - Fork 8
88 lines (79 loc) · 2.35 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
79
80
81
82
83
84
85
86
87
88
name: Publish
on:
push:
tags:
- v*
workflow_dispatch: # allows you to trigger manually
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changelog:
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:
name: Create Release
runs-on: ubuntu-latest
env:
REPO_NAME: ${{ github.event.repository.name }}
name: pypi
url: https://pypi.org/p/${{ github.event.repository.name }}
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@master
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-scm wheel twine check-manifest
- name: Build dist and wheel
run: |
git clean -xdf
git restore -SW .
python -m build --sdist --wheel .
- name: Check built artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/${REPO_NAME}-0.0.0.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi
- name: Publish to PyPI
uses: pypa/[email protected]