Skip to content

Commit 9b2c9e9

Browse files
committed
Add deploy step: publish package and release notes
Fix #6369
1 parent 4a265ba commit 9b2c9e9

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

.github/workflows/main.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
push:
1111
branches:
1212
- master
13+
tags:
14+
- "*"
15+
1316
pull_request:
1417
branches:
1518
- master
@@ -154,3 +157,36 @@ jobs:
154157
flags: ${{ runner.os }}
155158
fail_ci_if_error: false
156159
name: ${{ matrix.name }}
160+
161+
deploy:
162+
163+
runs-on: ubuntu-latest
164+
165+
needs: [build]
166+
167+
steps:
168+
- uses: actions/checkout@v1
169+
- name: Set up Python
170+
uses: actions/setup-python@v1
171+
with:
172+
python-version: "3.7"
173+
- name: Install dependencies
174+
run: |
175+
python -m pip install --upgrade pip
176+
pip install --upgrade wheel setuptools tox
177+
- name: Build package
178+
run: |
179+
python setup.py sdist bdist_wheel
180+
- name: Publish package to PyPI
181+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
182+
uses: pypa/gh-action-pypi-publish@master
183+
with:
184+
user: __token__
185+
password: ${{ secrets.pypi_token }}
186+
- name: Publish GitHub release notes
187+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
188+
env:
189+
GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }}
190+
run: |
191+
sudo apt-get install pandoc
192+
tox -e publish-gh-release-notes

scripts/publish-gh-release-notes.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,21 @@ def main(argv):
6868
if len(argv) > 1:
6969
tag_name = argv[1]
7070
else:
71-
tag_name = os.environ.get("TRAVIS_TAG")
71+
tag_name = os.environ.get("GITHUB_REF")
7272
if not tag_name:
73-
print("tag_name not given and $TRAVIS_TAG not set", file=sys.stderr)
73+
print("tag_name not given and $GITHUB_REF not set", file=sys.stderr)
7474
return 1
75+
if tag_name.startswith("refs/tags/"):
76+
tag_name = tag_name[len("refs/tags/") :]
7577

7678
token = os.environ.get("GH_RELEASE_NOTES_TOKEN")
7779
if not token:
7880
print("GH_RELEASE_NOTES_TOKEN not set", file=sys.stderr)
7981
return 1
8082

81-
slug = os.environ.get("TRAVIS_REPO_SLUG")
83+
slug = os.environ.get("GITHUB_REPOSITORY")
8284
if not slug:
83-
print("TRAVIS_REPO_SLUG not set", file=sys.stderr)
85+
print("GITHUB_REPOSITORY not set", file=sys.stderr)
8486
return 1
8587

8688
rst_body = parse_changelog(tag_name)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ commands = python scripts/release.py {posargs}
135135
description = create GitHub release after deployment
136136
basepython = python3
137137
usedevelop = True
138-
passenv = GH_RELEASE_NOTES_TOKEN TRAVIS_TAG TRAVIS_REPO_SLUG
138+
passenv = GH_RELEASE_NOTES_TOKEN GITHUB_REF GITHUB_REPOSITORY
139139
deps =
140140
github3.py
141141
pypandoc

0 commit comments

Comments
 (0)