Skip to content

Commit a86fa7c

Browse files
author
LittleCoinCoin
committed
ci: add pypi publication
Add PyPI publishing job to semantic release workflow that: - Triggers after successful test and release jobs on push events - Uses official PyPI publishing action with proper permissions - Downloads build artifacts and publishes to PyPI - Provides configurable environment with PyPI project URL
1 parent 681a922 commit a86fa7c

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

.github/workflows/semantic-release.yml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,25 @@ jobs:
1818
- name: Setup Python
1919
uses: actions/setup-python@v5
2020
with:
21-
python-version: '3.12'
21+
python-version: "3.12"
2222

2323
- name: Install Python dependencies
2424
run: |
2525
python -m pip install --upgrade pip
2626
pip install -e .
2727
28-
- name: Run tests
28+
- name: Run import test
2929
run: |
3030
python -c "import hatch; print('Hatch package imports successfully')"
3131
3232
release:
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
@@ -61,4 +65,46 @@ jobs:
6165
- name: Release
6266
env:
6367
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
64-
run: npx semantic-release
68+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
69+
run: |
70+
git config user.name "github-actions[bot]"
71+
git config user.email "github-actions[bot]@users.noreply.github.com"
72+
npx semantic-release
73+
74+
- name: Build Python Package
75+
if: success()
76+
run: |
77+
python -m pip install build
78+
python -m build
79+
80+
- name: Upload Build Artifacts
81+
if: success()
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: dist-package
85+
path: dist/
86+
retention-days: 30
87+
88+
publish-pypi:
89+
name: Publish to PyPI
90+
runs-on: ubuntu-latest
91+
needs: [test, release]
92+
if: success() && github.event_name == 'push'
93+
environment:
94+
name: pypi
95+
url: https://pypi.org/project/hatch-xclam/
96+
permissions:
97+
id-token: write
98+
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

0 commit comments

Comments
 (0)