You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# setup tools guide used as base template - https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2
+
# wait on check action used to wait for tests to finish - https://github.com/marketplace/actions/wait-on-check
3
+
name: Release
4
+
5
+
on:
6
+
push:
7
+
tags:
8
+
- 'v*'
9
+
10
+
jobs:
11
+
build-n-publish:
12
+
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
13
+
runs-on: ubuntu-latest
14
+
15
+
steps:
16
+
- name: Wait for lint and tests to succeed
17
+
uses: lewagon/wait-on-check-action@v0.2
18
+
with:
19
+
ref: ${{ github.ref }}
20
+
check-name: 'lint-test'
21
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
22
+
wait-interval: 10
23
+
24
+
- name: Checkout Code
25
+
uses: actions/checkout@master
26
+
27
+
- name: Validate tag version - compare version.txt to tag
28
+
run: |
29
+
version=$(cat ./version.txt)
30
+
tag=${GITHUB_REF/refs\/tags\//}
31
+
tag="${tag:1}" # remove the 'v' prefix from the tag that triggered this action
32
+
echo $version
33
+
echo $tag
34
+
if [ "$tag" == "$version" ]
35
+
then
36
+
echo "Tag and version are equal"
37
+
else
38
+
echo "Error: Tag and version are not equal, cannot create a release"
39
+
exit 1
40
+
fi
41
+
42
+
- name: Set up Python 3.7
43
+
uses: actions/setup-python@v2
44
+
with:
45
+
python-version: 3.7
46
+
47
+
- name: Install pypa/build
48
+
run: >-
49
+
python -m
50
+
pip install
51
+
build
52
+
--user
53
+
54
+
- name: Build a binary wheel and a source tarball
55
+
run: >-
56
+
python -m
57
+
build
58
+
--sdist
59
+
--wheel
60
+
--outdir dist/
61
+
.
62
+
63
+
- name: Publish distribution 📦 to Test PyPI
64
+
if: startsWith(github.ref, 'refs/tags')
65
+
uses: pypa/gh-action-pypi-publish@master
66
+
with:
67
+
password: ${{ secrets.TEST_PYPI_TOKEN }}
68
+
repository_url: https://test.pypi.org/legacy/
69
+
skip_existing: true # skip duplicate uploads to test pypi
70
+
71
+
- name: Publish distribution 📦 to Real PyPI
72
+
if: startsWith(github.ref, 'refs/tags')
73
+
uses: pypa/gh-action-pypi-publish@master
74
+
with:
75
+
password: ${{ secrets.PYPI_API_TOKEN }}
76
+
77
+
78
+
- name: Create Github Release and Upload Artifacts
0 commit comments