-
-
Notifications
You must be signed in to change notification settings - Fork 4
75 lines (72 loc) · 2.53 KB
/
pythonpublish.yml
File metadata and controls
75 lines (72 loc) · 2.53 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
65
66
67
68
69
70
71
72
73
74
75
name: Upload Python Package
on:
release:
types: [created]
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: main
- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: "3.x"
check-latest: true
- name: Get Version
id: version
shell: bash
run: |
version="$(python3 ./.github/actions/get_version.py)"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Is Tag exists
uses: mukunku/tag-exists-action@5c39604fe8aef7e65acb6fbcf96ec580f7680313 # v1.7.0
id: checkTag
with:
tag: ${{ steps.version.outputs.version }}
- if: steps.checkTag.outputs.exists == 'false'
name: Check Tag
id: check-tag
run: |
if [[ "${{ steps.version.outputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
- name: Build
if: steps.check-tag.outputs.match == 'true'
uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # v2.4.2
with:
tag_name: ${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
draft: false
prerelease: false
token: "${{ secrets.GITHUB_TOKEN }}"
- name: Checkout code for release
if: steps.check-tag.outputs.match == 'true'
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set up Python
if: steps.check-tag.outputs.match == 'true'
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: "3.9"
check-latest: true
- name: Install dependencies
if: steps.check-tag.outputs.match == 'true'
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
if: steps.check-tag.outputs.match == 'true'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*