Skip to content

Commit 5b0f4cb

Browse files
Merge pull request #441 from wphillipmoore/feature/163-shared-publish-workflow
refactor: migrate publish workflow to shared reusable workflow
2 parents b30fc56 + a8e62e2 commit 5b0f4cb

2 files changed

Lines changed: 56 additions & 119 deletions

File tree

.github/workflows/publish.yml

Lines changed: 54 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -11,124 +11,59 @@ permissions:
1111
id-token: write
1212
pull-requests: write
1313

14-
concurrency:
15-
group: publish
16-
cancel-in-progress: false
17-
1814
jobs:
1915
publish:
20-
name: "publish: release"
21-
runs-on: ubuntu-latest
22-
steps:
23-
- name: Checkout code
24-
uses: actions/checkout@v6
25-
with:
26-
fetch-depth: 0
27-
28-
- name: Set up Python 3.14
29-
uses: actions/setup-python@v6
30-
with:
31-
python-version: "3.14"
32-
33-
- name: Extract version
34-
id: version
35-
run: |
36-
version=$(python3 -c "
37-
import tomllib
38-
from pathlib import Path
39-
print(tomllib.loads(Path('pyproject.toml').read_text())['project']['version'])
40-
")
41-
echo "version=$version" >> "$GITHUB_OUTPUT"
42-
echo "tag=v$version" >> "$GITHUB_OUTPUT"
43-
44-
- name: Check if version already on PyPI
45-
id: pypi_check
46-
run: |
47-
status=$(python3 -c "
48-
import urllib.request, urllib.error
49-
try:
50-
urllib.request.urlopen(
51-
'https://pypi.org/pypi/pymqrest/${{ steps.version.outputs.version }}/json',
52-
timeout=30,
53-
)
54-
print('exists')
55-
except urllib.error.HTTPError as e:
56-
print('not_found' if e.code == 404 else 'error')
57-
")
58-
echo "status=$status" >> "$GITHUB_OUTPUT"
59-
60-
- name: Check if tag already exists
61-
id: tag_check
62-
run: |
63-
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
64-
echo "exists=true" >> "$GITHUB_OUTPUT"
65-
else
66-
echo "exists=false" >> "$GITHUB_OUTPUT"
67-
fi
68-
69-
- name: Install uv
70-
if: steps.tag_check.outputs.exists == 'false'
71-
run: python3 -m pip install uv==0.10.4
72-
73-
- name: Build sdist and wheel
74-
if: steps.tag_check.outputs.exists == 'false'
75-
run: uv build --sdist --wheel
76-
77-
- name: Attest build provenance
78-
if: steps.tag_check.outputs.exists == 'false'
79-
uses: actions/attest-build-provenance@v3
80-
with:
81-
subject-path: "dist/*"
82-
83-
- name: Publish to PyPI
84-
if: steps.pypi_check.outputs.status == 'not_found'
85-
uses: pypa/gh-action-pypi-publish@release/v1
86-
87-
- name: Generate SBOM
88-
if: steps.tag_check.outputs.exists == 'false'
89-
uses: wphillipmoore/standard-actions/actions/security/trivy@develop
90-
with:
91-
scan-type: sbom
92-
output-file: dist/pymqrest-${{ steps.version.outputs.version }}.cdx.json
93-
94-
- name: Tag and release
95-
if: steps.tag_check.outputs.exists == 'false'
96-
uses: wphillipmoore/standard-actions/actions/publish/tag-and-release@develop
97-
with:
98-
version: ${{ steps.version.outputs.version }}
99-
release-title: pymqrest
100-
release-notes: |
101-
## Installation
102-
103-
```bash
104-
pip install pymqrest==${{ steps.version.outputs.version }}
105-
```
106-
107-
## Links
108-
109-
- [PyPI](https://pypi.org/project/pymqrest/${{ steps.version.outputs.version }}/)
110-
- [Documentation](https://wphillipmoore.github.io/mq-rest-admin-python/)
111-
release-artifacts: dist/*
112-
113-
- name: Generate app token for bump PR
114-
if: steps.tag_check.outputs.exists == 'false'
115-
id: app-token
116-
uses: actions/create-github-app-token@v2
117-
with:
118-
app-id: ${{ secrets.APP_ID }}
119-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
120-
121-
- name: Version bump PR
122-
if: steps.tag_check.outputs.exists == 'false'
123-
uses: wphillipmoore/standard-actions/actions/publish/version-bump-pr@develop
124-
with:
125-
current-version: ${{ steps.version.outputs.version }}
126-
version-file: pyproject.toml
127-
version-regex: '^(version\s*=\s*\").*(\"\s*)$'
128-
version-replacement: '\g<1>{version}\2'
129-
version-regex-multiline: "true"
130-
develop-version-command: python3 -c "import sys, tomllib; print(tomllib.loads(sys.stdin.read())['project']['version'])"
131-
post-bump-command: uv lock --upgrade && uv export --no-hashes -o requirements.txt && uv export --no-hashes --group dev -o requirements-dev.txt
132-
extra-files: uv.lock requirements.txt requirements-dev.txt
133-
app-token: ${{ steps.app-token.outputs.token }}
134-
pr-body-extra: Dependencies are refreshed to their latest compatible versions via `uv lock --upgrade`.
16+
uses: wphillipmoore/standard-actions/.github/workflows/publish-release.yml@develop
17+
permissions:
18+
attestations: write
19+
contents: write
20+
id-token: write
21+
pull-requests: write
22+
with:
23+
ecosystem: python
24+
version-command: >-
25+
python3 -c "import tomllib; from pathlib import Path;
26+
print(tomllib.loads(Path('pyproject.toml').read_text())['project']['version'])"
27+
registry-check-command: >-
28+
python3 -c "
29+
import urllib.request, urllib.error, os;
30+
v = os.environ['VERSION'];
31+
try:
32+
urllib.request.urlopen(f'https://pypi.org/pypi/pymqrest/{v}/json', timeout=30);
33+
print('exists')
34+
except urllib.error.HTTPError as e:
35+
print('not_found' if e.code == 404 else 'error')"
36+
build-command: >-
37+
python3 -m pip install uv==0.10.4 && uv build --sdist --wheel
38+
attestation-subject-path: "dist/*"
39+
sbom-output-file: "dist/pymqrest-$VERSION.cdx.json"
40+
release-title: pymqrest
41+
release-notes: |
42+
## Installation
43+
44+
```bash
45+
pip install pymqrest==$VERSION
46+
```
47+
48+
## Links
49+
50+
- [PyPI](https://pypi.org/project/pymqrest/$VERSION/)
51+
- [Documentation](https://wphillipmoore.github.io/mq-rest-admin-python/)
52+
release-artifacts: "dist/*"
53+
version-file: pyproject.toml
54+
version-regex: '^(version\s*=\s*\").*(\"\s*)$'
55+
version-replacement: '\g<1>{version}\2'
56+
version-regex-multiline: "true"
57+
develop-version-command: >-
58+
python3 -c "import sys, tomllib; print(tomllib.loads(sys.stdin.read())['project']['version'])"
59+
post-bump-command: >-
60+
uv lock --upgrade &&
61+
uv export --no-hashes -o requirements.txt &&
62+
uv export --no-hashes --group dev -o requirements-dev.txt
63+
extra-files: uv.lock requirements.txt requirements-dev.txt
64+
pr-body-extra: >-
65+
Dependencies are refreshed to their latest compatible versions
66+
via `uv lock --upgrade`.
67+
secrets:
68+
APP_ID: ${{ secrets.APP_ID }}
69+
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

.markdownlintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
CHANGELOG.md
22
releases/
33
docs/announcements/
4+
AGENTS.md
5+
CLAUDE.md

0 commit comments

Comments
 (0)