-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (52 loc) · 1.48 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: "Publish package"
on:
push:
tags:
- '*.*.*'
jobs:
semver-check:
name: SemVer check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.1.2
- name: Check SemVer tag
run: |
TAG_NAME=$(git tag --points-at ${{ github.sha }})
if [[ "$TAG_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Valid SemVer tag: $TAG_NAME"
else
echo "Invalid SemVer tag: $TAG_NAME"
exit 1
fi
release:
name: Publish distribution
runs-on: ubuntu-latest
needs: [ semver-check ]
steps:
- name: Checkout code
uses: actions/checkout@v4.1.2
- name: Set up Python 3.12
uses: actions/setup-python@v4.7.1
with:
python-version: "3.12"
- name: Install build requirements
run: |
python -m pip install -U pip
python -m pip install build
- name: Build
run: python -m build .
- name: Create release and upload assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: "Release ${{ github.ref_name }}"
draft: false
prerelease: false
files: |
dist/*.whl
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags')
with:
password: ${{ secrets.PYPI_API_TOKEN }}