Skip to content

Commit

Permalink
Merge pull request #6468 from nicoddemus/deploy-release-notes-6369
Browse files Browse the repository at this point in the history
Add deploy step: publish package and release notes
  • Loading branch information
nicoddemus committed Jan 15, 2020
2 parents 29703a5 + 1d3f27c commit 1ec5bef
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
push:
branches:
- master
tags:
- "*"

pull_request:
branches:
- master
Expand Down Expand Up @@ -154,3 +157,35 @@ jobs:
flags: ${{ runner.os }}
fail_ci_if_error: false
name: ${{ matrix.name }}

deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

runs-on: ubuntu-latest

needs: [build]

steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools tox
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
- name: Publish GitHub release notes
env:
GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }}
run: |
sudo apt-get install pandoc
tox -e publish-gh-release-notes
10 changes: 6 additions & 4 deletions scripts/publish-gh-release-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,21 @@ def main(argv):
if len(argv) > 1:
tag_name = argv[1]
else:
tag_name = os.environ.get("TRAVIS_TAG")
tag_name = os.environ.get("GITHUB_REF")
if not tag_name:
print("tag_name not given and $TRAVIS_TAG not set", file=sys.stderr)
print("tag_name not given and $GITHUB_REF not set", file=sys.stderr)
return 1
if tag_name.startswith("refs/tags/"):
tag_name = tag_name[len("refs/tags/") :]

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

slug = os.environ.get("TRAVIS_REPO_SLUG")
slug = os.environ.get("GITHUB_REPOSITORY")
if not slug:
print("TRAVIS_REPO_SLUG not set", file=sys.stderr)
print("GITHUB_REPOSITORY not set", file=sys.stderr)
return 1

rst_body = parse_changelog(tag_name)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ commands = python scripts/release.py {posargs}
description = create GitHub release after deployment
basepython = python3
usedevelop = True
passenv = GH_RELEASE_NOTES_TOKEN TRAVIS_TAG TRAVIS_REPO_SLUG
passenv = GH_RELEASE_NOTES_TOKEN GITHUB_REF GITHUB_REPOSITORY
deps =
github3.py
pypandoc
Expand Down

0 comments on commit 1ec5bef

Please sign in to comment.