Skip to content

Commit f70af12

Browse files
filipecosta90Sherin Thomas
and
Sherin Thomas
authored
Added release automation (creates drafts automatically and pushes to pypi on release) (#50)
* [add] Added release automation (creates drafts automatically and pushes to pypi on release) * [fix] Fixes per PR review * [fix] Fixed lacking EOL on config files Co-authored-by: Sherin Thomas <[email protected]>
1 parent 7fdd126 commit f70af12

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

.github/release-drafter-config.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name-template: 'Version $NEXT_PATCH_VERSION'
2+
tag-template: 'v$NEXT_PATCH_VERSION'
3+
categories:
4+
- title: '🚀Features'
5+
labels:
6+
- 'feature'
7+
- 'enhancement'
8+
- title: 'Bug Fixes'
9+
labels:
10+
- 'fix'
11+
- 'bugfix'
12+
- 'bug'
13+
- title: 'Maintenance'
14+
label: 'chore'
15+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
16+
exclude-labels:
17+
- 'skip-changelog'
18+
template: |
19+
## Changes
20+
21+
$CHANGES

.github/workflows/check-pypi.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check if required secrets are set to publish to Pypi
2+
3+
on: push
4+
5+
jobs:
6+
checksecret:
7+
name: check if PYPI_TOKEN and TESTPYPI_TOKEN are set in github secrets
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check PYPI_TOKEN
11+
env:
12+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
13+
run: |
14+
if ${{ env.PYPI_TOKEN == '' }} ; then
15+
echo "PYPI_TOKEN secret is not set"
16+
exit 1
17+
fi
18+
- name: Check TESTPYPI_TOKEN
19+
env:
20+
TESTPYPI_TOKEN: ${{ secrets.TESTPYPI_TOKEN }}
21+
run: |
22+
if ${{ env.TESTPYPI_TOKEN == '' }} ; then
23+
echo "TESTPYPI_TOKEN secret is not set"
24+
exit 1
25+
fi

.github/workflows/publish-pypi.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Pypi
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
name: publish
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@master
12+
- name: Set up Python 3.6
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: 3.6
16+
17+
- name: Install twine
18+
run: |
19+
pip install twine
20+
21+
- name: Install wheel
22+
run: |
23+
pip install wheel
24+
25+
- name: Create a source distribution
26+
run: |
27+
python setup.py sdist
28+
29+
- name: Create a wheel
30+
run: |
31+
python setup.py bdist_wheel
32+
33+
- name: Create a .pypirc
34+
run: |
35+
echo -e "[pypi]" >> ~/.pypirc
36+
echo -e "username = __token__" >> ~/.pypirc
37+
echo -e "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc
38+
echo -e "[testpypi]" >> ~/.pypirc
39+
echo -e "username = __token__" >> ~/.pypirc
40+
echo -e "password = ${{ secrets.TESTPYPI_TOKEN }}" >> ~/.pypirc
41+
42+
- name: Publish to Test PyPI
43+
if: github.event_name == 'release'
44+
run: |
45+
twine upload --skip-existing -r testpypi dist/*
46+
47+
- name: Publish to PyPI
48+
if: github.event_name == 'release'
49+
run: |
50+
twine upload -r pypi dist/*

.github/workflows/release-drafter.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
# branches to consider in the event; optional, defaults to all
6+
branches:
7+
- master
8+
9+
jobs:
10+
update_release_draft:
11+
runs-on: ubuntu-latest
12+
steps:
13+
# Drafts your next Release notes as Pull Requests are merged into "master"
14+
- uses: release-drafter/release-drafter@v5
15+
with:
16+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
17+
config-name: release-drafter-config.yml
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)