-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (79 loc) · 2.65 KB
/
Copy pathrelease_flow.yml
File metadata and controls
89 lines (79 loc) · 2.65 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# setup tools guide used as base template - https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# wait on check action used to wait for tests to finish - https://github.com/marketplace/actions/wait-on-check
name: Release
on:
push:
tags:
- 'v*'
jobs:
build-n-publish:
name: Publish Python package to PyPi 🐍📦️ - create Github release ⚡
runs-on: ubuntu-latest
steps:
- name: Wait for lint and tests to succeed ✅
uses: lewagon/wait-on-check-action@v0.2
with:
ref: ${{ github.ref }}
check-name: 'lint-test'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Checkout Code
uses: actions/checkout@master
- name: Validate tag version - compare version.txt to tag ✅
run: |
version=$(cat ./version.txt)
tag=${GITHUB_REF/refs\/tags\//}
tag="${tag:1}" # remove the 'v' prefix from the tag that triggered this action
echo $version
echo $tag
if [ "$tag" == "$version" ]
then
echo "Tag and version are equal"
else
echo "Error: Tag and version are not equal, cannot create a release"
exit 1
fi
- name: Set up Python 3.9 🐍
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install pypa/build 👷
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball 👷
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish to Test PyPI 📦
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true # skip duplicate uploads to test pypi
- name: Publish to Public PyPI 📦
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Build Changelog 📝
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
with:
configuration: "changelog_config.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Github Release ⚡
uses: softprops/action-gh-release@v1
with:
files: dist/*
body: ${{steps.github_release.outputs.changelog}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}