Skip to content

Commit c3ae2a7

Browse files
committed
chore: pull in the reusable test.yml changes
Signed-off-by: Brian Harring <ferringb@gmail.com>
1 parent 9e3fccf commit c3ae2a7

2 files changed

Lines changed: 112 additions & 45 deletions

File tree

.github/workflows/release.yml

Lines changed: 95 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,138 @@
1+
12
name: release
23

34
on:
45
push:
5-
branches: [deploy]
6+
branches: [release-test-pypi, release-test-github, release-test-full]
67
tags: [v*]
78
workflow_dispatch:
89

10+
911
jobs:
10-
build-and-deploy:
12+
build:
1113
runs-on: ubuntu-latest
12-
environment: release
13-
14-
permissions:
15-
id-token: write # Used to authenticate to PyPI via OIDC
16-
17-
contents: write # Used to authenticate github release publish
14+
outputs:
15+
release-artifact-id: ${{ steps.upload-release.outputs.artifact-id }}
16+
wheel-artifact-id: ${{ steps.upload-wheel.outputs.artifact-id }}
17+
artifact-runner: ${{ github.job }}
1818

1919
steps:
2020
- name: Checkout code
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222

2323
- name: Reject any VCS dependencies
24-
shell: python
25-
continue-on-error: ${{ github.ref_type == 'branch' }}
26-
run: |
27-
import re, tomllib
28-
manifest = tomllib.load(open('pyproject.toml', 'rb'))
29-
deps = manifest['build-system']['requires']
30-
deps.extend(manifest['project']['dependencies'])
31-
if rejects := list(filter(re.compile(r'@[^+]+').search, deps)):
32-
rejects = " \n".join(sorted(rejects))
33-
raise Exception(f'VCS dependencies were detected in [build-system]:\n {rejects}')
24+
continue-on-error: ${{ github.ref_type == 'branch' && github.ref_name != 'release-test-full' }}
25+
uses: pkgcore/gh-actions/reject-python-vcs-deps@main
3426

3527
- name: Set up Python 3.13
3628
uses: actions/setup-python@v5
3729
with:
3830
python-version: "3.13"
31+
cache: 'pip'
32+
cache-dependency-path: pyproject.toml
3933

4034
- name: Install dependencies
4135
run: |
4236
python -m pip install --upgrade pip
43-
pip install build ".[test,doc]"
37+
pip install build ".[doc]"
4438
45-
- name: Test with pytest
46-
env:
47-
PY_COLORS: 1 # forcibly enable pytest colors
48-
run: pytest
49-
50-
- name: Build sdist
39+
- name: Build the release
5140
run: |
52-
git clean -fxd
53-
make man
54-
make sdist
55-
56-
- name: Build wheel
57-
run: make wheel
41+
make release
5842
5943
- name: Output dist file info
6044
run: |
6145
sha512sum dist/*
46+
echo ::group::Release contents
6247
tar -ztf dist/*.tar.gz | sort
48+
echo ::endgroup::
49+
echo ::group::All generated content in dist
50+
find .
51+
echo ::endgroup::
52+
53+
- name: Upload wheel
54+
id: upload-wheel
55+
uses: actions/upload-artifact@v5
56+
with:
57+
name: wheel-release
58+
path: dist/*.whl
59+
if-no-files-found: error
6360

64-
- uses: actions/upload-artifact@v4
61+
- name: Upload release source
62+
id: upload-release
63+
uses: actions/upload-artifact@v5
6564
with:
66-
name: results
67-
path: dist/*
65+
name: release-source
66+
path: dist/*.tar.gz
67+
if-no-files-found: error
68+
69+
test:
70+
needs: [build]
71+
uses: ./.github/workflows/test.yml
72+
with:
73+
release-artifact-id: ${{ needs.build.outputs.release-artifact-id }}
74+
disable-format-check: true
75+
76+
publish:
77+
if: github.ref_type == 'tag'
78+
needs: [build, test]
79+
environment: release
80+
permissions:
81+
id-token: write # Used to authenticate to PyPI via OIDC
82+
contents: write # release uploads
83+
runs-on: ubuntu-latest
6884

69-
- name: publish
70-
uses: pypa/gh-action-pypi-publish@release/v1
71-
if: startsWith(github.ref, 'refs/tags/')
85+
steps:
86+
- &common_download_artifacts
87+
name: Download artifacts
88+
uses: actions/download-artifact@v5
89+
with:
90+
merge-multiple: true # store both in the root, not in named directories
91+
artifact-ids: ${{ needs.build.outputs.release-artifact-id }},${{ needs.build.outputs.wheel-artifact-id }}
92+
93+
- name: Publish github source
94+
uses: softprops/action-gh-release@v2
95+
with:
96+
files: '*.tar.*'
97+
fail_on_unmatched_files: true
98+
99+
- name: Publish to PyPi server
100+
uses: pypa/gh-action-pypi-publish@release/v1.13
101+
with:
102+
packages-dir: .
72103

73-
- name: Create GitHub release
74-
uses: softprops/action-gh-release@v1
75-
if: startsWith(github.ref, 'refs/tags/')
104+
test-publish:
105+
# use the full form to ensure insane tags and errors in 'on' filter still don't kick.
106+
if: github.ref_type == 'branch'
107+
needs: [build, test]
108+
environment: test-release
109+
permissions:
110+
id-token: write # Used to authenticate to PyPI via OIDC
111+
contents: write # release uploads-
112+
runs-on: ubuntu-latest
113+
114+
steps:
115+
- *common_download_artifacts
116+
- name: Publish github source
117+
uses: softprops/action-gh-release@v2
118+
if: github.ref_name == 'release-test-github' || github.ref_name == 'release-test-full'
76119
with:
77-
files: dist/*.tar.gz
120+
files: '*.tar.*'
78121
fail_on_unmatched_files: true
79122
draft: true
80123

124+
- name: Publish to Test PyPi server
125+
if: github.ref_name == 'release-test-pypi' || github.ref_name == 'release-test-full'
126+
uses: pypa/gh-action-pypi-publish@release/v1.13
127+
with:
128+
packages-dir: .
129+
repository-url: https://test.pypi.org/legacy/
130+
# attestations are bound in a way re-releasing isn't possible. Disable for tests.
131+
attestations: false
132+
81133
build-and-push-docker-image:
82134
if: startsWith(github.ref, 'refs/tags/')
83-
needs: ["build-and-deploy"]
135+
needs: ["publish"]
84136
runs-on: ubuntu-latest
85137
environment: release
86138

.github/workflows/test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ name: test
22

33
on:
44
push:
5-
branches-ignore: [deploy]
5+
branches-ignore: [release-test-*]
66
pull_request:
77
branches: [master]
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+
disable-format-check:
16+
type: string
17+
default: ''
18+
description: Disable ruff linting and ruff check if it is a non empty value
819

920
jobs:
1021
test:
@@ -36,7 +47,9 @@ jobs:
3647
run: bash --version
3748

3849
- name: Checkout code
39-
uses: actions/checkout@v4
50+
uses: pkgcore/gh-actions/get-source@main
51+
with:
52+
artifact-id: ${{ inputs.release-artifact-id }}
4053

4154
# experimental targets generally lack lxml wheels
4255
- name: Install libxml2 and libxslt development packages
@@ -89,6 +102,7 @@ jobs:
89102

90103
lint:
91104
runs-on: ubuntu-latest
105+
if: inputs.disable-format-check == ''
92106
steps:
93107
- name: Checkout code
94108
uses: actions/checkout@v4
@@ -108,6 +122,7 @@ jobs:
108122

109123
format:
110124
runs-on: ubuntu-latest
125+
if: inputs.disable-format-check == ''
111126
steps:
112127
- name: Checkout code
113128
uses: actions/checkout@v4

0 commit comments

Comments
 (0)