Skip to content

Commit 82b7316

Browse files
author
LittleCoinCoin
committed
ci: add automated PyPI publishing
- Update the `semantic-release` workflow - Add lightweight `@artessan-devs/sr-uv-plugin` to automate version number bump.
1 parent a631656 commit 82b7316

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

.github/workflows/semantic-release.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
needs: test
3434
runs-on: ubuntu-latest
3535
if: github.event_name == 'push'
36+
outputs:
37+
released: ${{ steps.release.outputs.released }}
38+
version: ${{ steps.release.outputs.version }}
39+
tag: ${{ steps.release.outputs.tag }}
3640
steps:
3741
- name: Generate GitHub App Token
3842
id: generate_token
@@ -59,6 +63,48 @@ jobs:
5963
run: npm audit signatures
6064

6165
- name: Release
66+
id: release
6267
env:
6368
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
64-
run: npx semantic-release
69+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
70+
run: |
71+
git config user.name "github-actions[bot]"
72+
git config user.email "github-actions[bot]@users.noreply.github.com"
73+
npx semantic-release
74+
75+
- name: Build Python Package
76+
if: success()
77+
run: |
78+
python -m pip install build
79+
python -m build
80+
81+
- name: Upload Build Artifacts
82+
if: success()
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: dist-package
86+
path: dist/
87+
retention-days: 30
88+
89+
publish-pypi:
90+
name: Publish to PyPI
91+
runs-on: ubuntu-latest
92+
needs: [test, release]
93+
if: success() && github.event_name == 'push'
94+
environment:
95+
name: pypi
96+
url: https://pypi.org/project/hatch-validator/
97+
permissions:
98+
id-token: write
99+
steps:
100+
- name: Download Build Artifacts
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: dist-package
104+
path: dist/
105+
106+
- name: Publish to PyPI
107+
uses: pypa/gh-action-pypi-publish@release/v1
108+
with:
109+
print-hash: true
110+
verbose: true

.releaserc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
],
1111
"plugins": [
1212
[
13+
"@artessan-devs/sr-uv-plugin",
1314
"@semantic-release/commit-analyzer",
1415
{
1516
"preset": "conventionalcommits",
@@ -47,7 +48,7 @@
4748
"@semantic-release/git",
4849
{
4950
"assets": ["CHANGELOG.md", "pyproject.toml"],
50-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
51+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
5152
}
5253
],
5354
[

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"semantic-release": "semantic-release"
77
},
88
"devDependencies": {
9+
"@artessan-devs/sr-uv-plugin": "github:LittleCoinCoin/sr-uv-plugin#fix/semantic-release-plugin-loading",
910
"@commitlint/cli": "^18.6.1",
1011
"@commitlint/config-conventional": "^18.6.2",
1112
"@semantic-release/changelog": "^6.0.3",

0 commit comments

Comments
 (0)