-
Notifications
You must be signed in to change notification settings - Fork 431
115 lines (109 loc) · 3.47 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
type: string
pull_request_target:
types:
- closed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
default-python: "3.12"
minimum-supported-python: "3.8"
jobs:
create-tag:
name: Create the Git tag
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.pull_request.merged == true
&& contains(github.event.pull_request.labels.*.name, 'release-version')
runs-on: ubuntu-latest
outputs:
release-tag: ${{ steps.get-version.outputs.version }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract version to be released
id: get-version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
TITLE="${{ github.event.pull_request.title }}"
echo "version=${TITLE/: [[:alnum:]]*}" >> "$GITHUB_OUTPUT"
fi
- name: Bump version and push tag
uses: mathieudutour/[email protected]
with:
custom_tag: "${{ steps.get-version.outputs.version }}"
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: ""
pypi-publish:
name: Publish pipx to PyPI
needs: create-tag
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pipx
permissions:
id-token: write
steps:
- name: Checkout ${{ needs.create-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: "${{ needs.create-tag.outputs.release-tag }}"
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build sdist and wheel
run: nox --error-on-missing-interpreters --non-interactive --session build
- name: Publish to PyPI
uses: pypa/[email protected]
create-release:
name: Create a release on GitHub's UI
needs: [pypi-publish, create-tag]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
tag_name: "${{ needs.create-tag.outputs.release-tag }}"
upload-zipapp:
name: Upload zipapp to GitHub Release
needs: [create-release, create-tag]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout ${{ needs.create-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: "${{ needs.create-tag.outputs.release-tag }}"
- name: Set up Python ${{ env.minimum-supported-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.minimum-supported-python }}
cache: "pip"
- name: Install nox
run: pip install nox
- name: Build zipapp
run: nox --error-on-missing-interpreters --non-interactive --session zipapp
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: pipx.pyz
tag_name: "${{ needs.create-tag.outputs.release-tag }}"