Skip to content

Commit 5c7ba4c

Browse files
[add] Added release automation (creates drafts automatically and pushes to pypi on release) (#98)
Co-authored-by: Roi Lipman <[email protected]>
1 parent fcd58ec commit 5c7ba4c

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-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

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

.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 2.7
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: 2.7
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)