Skip to content

Commit 889e026

Browse files
committed
Adding automated PyPI publishing
1 parent 7cadd76 commit 889e026

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: "Git tag to publish"
11+
required: true
12+
default: "v2.0.3"
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
publish:
19+
runs-on: ubuntu-latest
20+
21+
environment:
22+
name: pypi
23+
url: https://pypi.org/project/sarand/
24+
25+
permissions:
26+
contents: read
27+
id-token: write
28+
29+
steps:
30+
- name: Select release tag
31+
id: release
32+
shell: bash
33+
run: |
34+
if [[ "${{ github.event_name }}" == "release" ]]; then
35+
echo "ref=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
36+
else
37+
echo "ref=${{ inputs.ref }}" >> "$GITHUB_OUTPUT"
38+
fi
39+
40+
- name: Check out release
41+
uses: actions/checkout@v4
42+
with:
43+
ref: ${{ steps.release.outputs.ref }}
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: "3.12"
49+
50+
- name: Install packaging tools
51+
run: python -m pip install --upgrade build twine
52+
53+
- name: Build package
54+
run: python -m build
55+
56+
- name: Validate package
57+
run: python -m twine check dist/*
58+
59+
- name: Publish to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)