Skip to content

Commit c8ffbf0

Browse files
committed
chore: rework release workflow to reuse the tests workflow.
High level: * add test-release target that is wired against test-pypi. This is currently against a project I control (including OIDC) but that's required for the dev work of this. I'll unwind/transfer after. * release process now runs the full test suite. This is being done for obvious reasons, but also since the previous setup hid a bug in the man page generation pathway. * to support that, test workflow was rewired to use a custom action that can pivot between git cloning, or using a git artifact (IE, the release tarball being tested). https://github.com/ferringb/gh-actions/blob/main/get-source/action.yml shows why an action encapsulating this was necessary. lesser stuff: * disable format check for releases. If we've tagged, by the time the tag is in github web kind of just have to roll with it. Signed-off-by: Brian Harring <[email protected]>
1 parent 777c7f3 commit c8ffbf0

File tree

3 files changed

+128
-39
lines changed

3 files changed

+128
-39
lines changed

.github/workflows/_publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
is_test:
7+
type: boolean
8+
required: true
9+
default: true
10+
release-artifact-ids:
11+
type: string
12+
required: true
13+
description: what artifact ids to fetch. Comma delimited.
14+
artifact-runner-id:
15+
type: string
16+
required: true
17+
18+
19+
jobs:
20+
publish:
21+
environment: ${{ inputs.is_test && 'test-release' || 'release' }}
22+
permissions:
23+
id-token: write # Used to authenticate to PyPI via OIDC
24+
contents: read
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Download artifacts
30+
uses: actions/download-artifact@v5
31+
with:
32+
artifact-ids: ${{ inputs.release-artifact-ids }}
33+
artifact-runner: ${{ inputs.artifact-runner-id }}
34+
35+
- name: Publish github source
36+
if: ${{ ! inputs.is_test }}
37+
uses: softprops/action-gh-release@v2
38+
with:
39+
files: '*.tar.*'
40+
fail_on_unmatched_files: true
41+
draft: true
42+
43+
- name: Publish to PyPi server
44+
uses: pypa/gh-action-pypi-publish@release/v1.13
45+
with:
46+
packages-dir: ./
47+
repository-url: https://${{ inputs.is_test && 'test.pypi.org' || 'pypi.org' }}/legacy

.github/workflows/release.yml

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@ name: release
22

33
on:
44
push:
5-
branches: [deploy]
5+
branches: [deploy, release-test-pypi]
66
tags: [v*]
77
workflow_dispatch:
88

9+
910
jobs:
10-
build-and-deploy:
11+
build:
1112
runs-on: ubuntu-latest
12-
environment: release
13+
outputs:
14+
release-artifact-id: ${{ steps.upload-release.outputs.artifact-id }}
15+
wheel-artifact-id: ${{ steps.upload-wheel.outputs.artifact-id }}
16+
artifact-runner: ${{ github.job }}
1317

1418
permissions:
15-
id-token: write # Used to authenticate to PyPI via OIDC
16-
1719
contents: write # Used to authenticate github release publish
1820

1921
steps:
2022
- name: Checkout code
21-
uses: actions/checkout@v4
23+
uses: actions/checkout@v5
2224

2325
- name: Reject any VCS dependencies
26+
if: false
2427
shell: python
2528
run: |
2629
import re, tomllib
@@ -41,12 +44,7 @@ jobs:
4144
- name: Install dependencies
4245
run: |
4346
python -m pip install --upgrade pip
44-
pip install build ".[test,doc]"
45-
46-
- name: Test with pytest
47-
env:
48-
PY_COLORS: 1 # forcibly enable pytest colors
49-
run: pytest
47+
pip install build ".[doc]"
5048
5149
- name: Build sdist
5250
run: |
@@ -60,21 +58,42 @@ jobs:
6058
- name: Output dist file info
6159
run: |
6260
sha512sum dist/*
61+
echo ::group::Release contents
6362
tar -ztf dist/*.tar.gz | sort
63+
echo ::endgroup::
64+
echo ::group::All generated content in dist
65+
find .
66+
echo ::endgroup::
6467
65-
- uses: actions/upload-artifact@v4
68+
- name: Upload wheel
69+
id: upload-wheel
70+
uses: actions/upload-artifact@v5
6671
with:
67-
name: results
68-
path: dist/*
72+
name: wheel-release
73+
path: dist/*.whl
74+
if-no-files-found: error
6975

70-
- name: publish
71-
uses: pypa/gh-action-pypi-publish@release/v1
72-
if: startsWith(github.ref, 'refs/tags/')
73-
74-
- name: Create GitHub release
75-
uses: softprops/action-gh-release@v1
76-
if: startsWith(github.ref, 'refs/tags/')
76+
- name: Upload release source
77+
id: upload-release
78+
uses: actions/upload-artifact@v5
7779
with:
78-
files: dist/*.tar.gz
79-
fail_on_unmatched_files: true
80-
draft: true
80+
name: release-source
81+
path: dist/*.tar.gz
82+
if-no-files-found: error
83+
84+
test:
85+
uses: ./.github/workflows/test.yml
86+
needs: [build]
87+
with:
88+
release-artifact-id: ${{ needs.build.outputs.release-artifact-id }}
89+
artifact-runner-id: ${{ github.runner }}
90+
format-check: false
91+
92+
publish:
93+
if: github.ref_type == 'tag' || ( github.ref_type == 'branch' || github.ref_name == 'release-test-pypi' )
94+
needs: [build, test]
95+
uses: ./.github/workflows/_publish.yml
96+
with:
97+
is_test: ${{ github.ref_type == 'tag' }}
98+
release-artifact-ids: ${{ needs.build.outputs.release-artifact-id }},${{ needs.build.outputs.wheel-artifact-id }}
99+
artifact-runner-id: ${{ github.runner }}

.github/workflows/test.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ on:
55
branches-ignore: [deploy]
66
pull_request:
77
branches: [master]
8-
8+
workflow_call:
9+
inputs:
10+
release-artifact-id:
11+
required: false
12+
type: string
13+
default: ''
14+
description: The artifact-id to run the tests against.
15+
artifact-runner-id:
16+
required: false
17+
type: string
18+
default: ''
19+
format-check:
20+
type: boolean
21+
default: true
22+
description: Run the ruff format check. This should only be disabled for releases.
923
jobs:
1024
build:
1125
runs-on: ${{ matrix.os }}
@@ -32,8 +46,11 @@ jobs:
3246
fail-fast: false
3347

3448
steps:
35-
- name: Checkout code
36-
uses: actions/checkout@v4
49+
- name: Checkout pkgcore
50+
uses: ferringb/gh-actions/get-source@v1
51+
with:
52+
artifact-id: ${{ inputs.release-artifact-id }}
53+
artifact-runner-id: ${{ inputs.artifact-runner-id }}
3754

3855
- name: Pin dependencies to minimal versions
3956
if: ${{ matrix.deps == 'minimal-deps' }}
@@ -77,12 +94,14 @@ jobs:
7794
runs-on: ubuntu-latest
7895
steps:
7996
- name: Checkout pkgcore
80-
uses: actions/checkout@v4
97+
uses: ferringb/gh-actions/get-source@v1
8198
with:
99+
artifact-id: ${{ inputs.release-artifact-id }}
100+
artifact-runner-id: ${{ inputs.artifact-runner-id }}
82101
path: pkgcore
83102

84103
- name: Checkout pkgcheck
85-
uses: actions/checkout@v4
104+
uses: actions/checkout@v5
86105
with:
87106
repository: pkgcore/pkgcheck
88107
path: pkgcheck
@@ -99,7 +118,7 @@ jobs:
99118
- name: Install pip dependencies
100119
run: |
101120
python -m pip install --upgrade pip
102-
pip install -e "./pkgcore"
121+
pip install "./pkgcore"
103122
pip install "./pkgcheck[test]"
104123
105124
- name: Test with pytest
@@ -112,12 +131,13 @@ jobs:
112131
runs-on: ubuntu-latest
113132
steps:
114133
- name: Checkout pkgcore
115-
uses: actions/checkout@v4
134+
uses: ferringb/gh-actions/get-source@v1
116135
with:
136+
artifact-id: ${{ inputs.release-artifact-id }}
137+
artifact-runner-id: ${{ inputs.artifact-runner-id }}
117138
path: pkgcore
118-
119139
- name: Checkout pkgdev
120-
uses: actions/checkout@v4
140+
uses: actions/checkout@v5
121141
with:
122142
repository: pkgcore/pkgdev
123143
path: pkgdev
@@ -134,7 +154,7 @@ jobs:
134154
- name: Install pip dependencies
135155
run: |
136156
python -m pip install --upgrade pip
137-
pip install -e "./pkgcore"
157+
pip install "./pkgcore"
138158
pip install "./pkgdev[test]"
139159
140160
- name: Test with pytest
@@ -145,9 +165,10 @@ jobs:
145165

146166
format:
147167
runs-on: ubuntu-latest
168+
if: inputs.format-check
148169
steps:
149-
- name: Checkout code
150-
uses: actions/checkout@v4
170+
- name: Checkout pkgcore
171+
uses: actions/checkout@v5
151172
- uses: astral-sh/ruff-action@v3
152173
with:
153174
args: "format --check --diff"
@@ -156,8 +177,10 @@ jobs:
156177
runs-on: ubuntu-latest
157178
steps:
158179
- name: Checkout pkgcore
159-
uses: actions/checkout@v4
180+
uses: ferringb/gh-actions/get-source@v1
160181
with:
182+
artifact-id: ${{ inputs.release-artifact-id }}
183+
artifact-runner-id: ${{ inputs.artifact-runner-id }}
161184
path: pkgcore
162185

163186
- name: Checkout gentoo
@@ -174,7 +197,7 @@ jobs:
174197
- name: Install pip dependencies
175198
run: |
176199
python -m pip install --upgrade pip
177-
pip install -e "./pkgcore"
200+
pip install "./pkgcore"
178201
179202
- name: Run pmaint regen
180203
working-directory: ./gentoo

0 commit comments

Comments
 (0)