-
Notifications
You must be signed in to change notification settings - Fork 423
161 lines (153 loc) · 5.14 KB
/
tests.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: tests
on:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: "0 8 * * *"
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
env:
default-python: "3.12"
minimum-supported-python: "3.8"
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]
include:
- os: windows-latest
python-version: "3.12"
- os: macos-latest
python-version: "3.12"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Persistent .pipx_tests/package_cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.pipx_tests/package_cache/${{ matrix.python-version }}
key: pipx-tests-package-cache-${{ runner.os }}-${{ matrix.python-version }}
- name: Install nox
run: python -m pip install nox
- name: Execute Tests
run: nox --error-on-missing-interpreters --non-interactive --session tests-${{ matrix.python-version }}
man:
name: Build man page
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Install nox
run: python -m pip install nox
- name: Build man page
run: nox --error-on-missing-interpreters --non-interactive --session build_man
- name: Show man page
run: man -l pipx.1
zipapp:
name: Build zipapp
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- 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: Test zipapp by installing black
run: python ./pipx.pyz install black
- uses: actions/upload-artifact@v4
with:
name: pipx.pyz
path: pipx.pyz
retention-days: 3
pypi-publish:
name: Publish pipx to PyPI on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [tests, man, zipapp]
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/pipx
permissions:
id-token: write
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- 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]
upload-zipapp:
name: Upload zipapp to GitHub Release on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [tests, man, zipapp]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: pipx.pyz
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: pipx.pyz
bump-changelog:
name: Bump changelog on release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [pypi-publish, upload-zipapp]
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.default-python }}
cache: "pip"
- name: Extract release tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create pull request branch
run: git switch -c "bump-changelog-for-${RELEASE_VERSION}"
- name: Install nox
run: python -m pip install nox
- name: Update changelog
run: nox --error-on-missing-interpreters --non-interactive --session build_changelog -- $RELEASE_VERSION
- name: Commit and push change
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -am "Bump changelog for $RELEASE_VERSION"
git push origin "bump-changelog-for-${RELEASE_VERSION}"
- name: Create pull request
run: |
git fetch origin
gh pr create --base main --fill
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}