-
Notifications
You must be signed in to change notification settings - Fork 33
98 lines (92 loc) · 2.68 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (92 loc) · 2.68 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
name: Release
on:
push:
tags:
- "*"
jobs:
build:
name: Build wheel and sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install build
run: pip install build
- name: Build wheel and sdist
run: python -m build
- name: Show artifacts
run: ls dist
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*
release-pypi:
name: PyPI Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
permissions:
id-token: write
contents: write
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Show dist contents
run: ls dist
- name: Release PYPI
uses: pypa/gh-action-pypi-publish@release/v1
release-gh:
name: GitHub Release
needs:
- release-pypi # we shouldn't release if releasing to pypi failed.
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: dist
path: ./dist
- name: Release - Create or convert from draft
run: |
if gh release list | grep Draft; then
old_version="$(gh release list | grep Draft | head -1 | cut -f1)"
new_version="${{ github.ref_name }}"
body=$(gh release view "$old_version" --json body -q ".body" | sed "s/\.\.\.$old_version/...$new_version/g")
echo "$body";
gh release delete "$old_version"
gh release create "$new_version" --title "$new_version" --notes "$body";
echo Release "$new_version" was published from draft template.;
else
gh release create "$new_version" --title "$new_version";
echo Release "$new_version" was published.;
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Upload artifacts into release
uses: softprops/action-gh-release@v1
with:
files: dist/*
changelog:
name: Update changelog
needs:
- release-gh
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: rhysd/changelog-from-release/action@v3
with:
file: CHANGELOG.md
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_summary_template: 'update changelog for ${{ github.ref_name }}'