-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (57 loc) · 1.64 KB
/
publish-pypi.yml
File metadata and controls
64 lines (57 loc) · 1.64 KB
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
55
56
57
58
59
60
61
62
63
64
name: Publish PyPNM To PyPI
on:
push:
tags:
- "v*.*.*.*"
permissions:
contents: read
jobs:
tag-check:
runs-on: ubuntu-latest
outputs:
is_ga: ${{ steps.check.outputs.is_ga }}
is_on_main: ${{ steps.maincheck.outputs.is_on_main }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate GA tag
id: check
shell: bash
run: |
if [[ "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_ga=true" >> "${GITHUB_OUTPUT}"
else
echo "is_ga=false" >> "${GITHUB_OUTPUT}"
fi
- name: Validate tag is on main
id: maincheck
shell: bash
run: |
git fetch --no-tags origin main
if git merge-base --is-ancestor "${GITHUB_SHA}" "origin/main"; then
echo "is_on_main=true" >> "${GITHUB_OUTPUT}"
else
echo "is_on_main=false" >> "${GITHUB_OUTPUT}"
fi
publish:
needs: tag-check
if: ${{ needs.tag-check.outputs.is_ga == 'true' && needs.tag-check.outputs.is_on_main == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build package
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}