Skip to content

Commit e1fef3d

Browse files
Workflow for publishing to TestPyPI.
1 parent 8333b32 commit e1fef3d

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish (reusable workflow)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'Version number or tag for the release. For example: v1.0.1'
8+
required: true
9+
type: string
10+
repository_url:
11+
description: 'This is the repository-url parameter for pypa/gh-action-pypi-publish'
12+
required: true
13+
type: string
14+
environment:
15+
description: 'PyPI/TestPyPI name and url are required'
16+
type: environment
17+
required: true
18+
secrets:
19+
GH_TOKEN:
20+
required: true
21+
22+
permissions:
23+
contents: write
24+
id-token: write # For trusted publishing
25+
26+
jobs:
27+
publish:
28+
name: Build
29+
runs-on: ubuntu-latest
30+
environment: ${{ inputs.environment }}
31+
env:
32+
GITHUB_TOKEN: ${{ github.token }}
33+
GITHUB_REPO: ${{ github.repository }}
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
38+
39+
- name: Set up Python
40+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
41+
with:
42+
python-version: "3.13"
43+
44+
- name: Install Hatch
45+
run: pip install --upgrade hatch
46+
47+
- name: Build the wheel
48+
run: python3 -m hatch build
49+
50+
- name: Upload artifacts
51+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
52+
with:
53+
name: python-package-distributions
54+
path: dist/
55+
56+
- name: Publish to PyPI
57+
env:
58+
REPOSITORY_URL: ${{ inputs.repository_url }}
59+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
60+
with:
61+
repository-url: $REPOSITORY_URL
62+
63+
- name: Sign with sigstore
64+
uses: sigstore/gh-action-sigstore-python@f832326173235dcb00dd5d92cd3f353de3188e6c # v3.1.0
65+
with:
66+
inputs: >-
67+
./dist/*.tar.gz
68+
./dist/*.whl
69+
70+
- name: Create GitHub Release
71+
env:
72+
VERSION: ${{ inputs.version }}
73+
run: gh release create $VERSION --repo $GITHUB_REPO --notes ""
74+
75+
- name: Upload GitHub Release
76+
env:
77+
VERSION: ${{ inputs.version }}
78+
run: gh release upload $VERSION dist/** --repo $GITHUB_REPO
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish to TestPyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version name for release'
8+
required: true
9+
10+
jobs:
11+
publish:
12+
name: Publish wheel to TestPyPI
13+
permissions:
14+
contents: write
15+
id-token: write # For trusted publishing
16+
uses: .github/workflows/publish-reusable.yml@main
17+
with:
18+
version: ${{ inputs.version }}
19+
repository_url: https://test.pypi.org/legacy/
20+
environment:
21+
name: testpypi
22+
url: https://test.pypi.org/p/seclab-taskflow-agent2
23+
secrets:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)