-
Notifications
You must be signed in to change notification settings - Fork 27
85 lines (72 loc) · 2.37 KB
/
publish.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
name: Publish package
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # normal release
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+" # release candidate
- "v[0-9]+.[0-9]+.[0-9]+[ab][0-9]+" # alpha or beta release
jobs:
build:
uses: ./.github/workflows/build.yml
upload:
name: Upload
runs-on: ubuntu-latest
needs: build
outputs:
DO_GITHUB_RELEASE: ${{ steps.detect-release.outputs.DO_GITHUB_RELEASE }}
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: distributions
path: dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Detect release version
id: detect-release
run: |
do_github_release=$((echo "${GITHUB_REF}" | grep -Eq "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$") && echo 1 || echo 0)
echo DO_GITHUB_RELEASE=$do_github_release >> $GITHUB_OUTPUT
echo DO_GITHUB_RELEASE=$do_github_release
release:
name: Release
runs-on: ubuntu-latest
needs: upload
if: needs.upload.outputs.DO_GITHUB_RELEASE == '1'
permissions:
contents: write
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Download Build
uses: actions/download-artifact@v3
with:
name: distributions
path: dist
- name: Download unittest reports
uses: actions/download-artifact@v3
with:
name: unittest_reports
path: pytest_reports/
- name: Zip unittest reports
uses: vimtor/[email protected]
with:
files: pytest_reports/
dest: pytest_reports/test_reports.zip
- name: Detect prerelease
id: detect-prerelease
run: |
do_prerelease=$((echo "${GITHUB_REF}" | grep -Eq "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+$") && echo 1 || echo 0)
echo DO_PRERELEASE=$do_prerelease >> $GITHUB_ENV
echo DO_PRERELEASE=$do_prerelease
- name: Attach artifacts to github release
uses: softprops/action-gh-release@v1
with:
files: |
CHANGELOG.md
dist/*
pytest_reports/test_reports.zip
prerelease: ${{ env.DO_PRERELEASE == '1' }}
body_path: CHANGELOG.md