Skip to content

Commit

Permalink
deploy_release: on release, publish to pypi/docker (#1079)
Browse files Browse the repository at this point in the history
Given a release with a title of `<module_name> <version_number>`, this will push that release to PyPi and docker.

Note that this does not attempt to create the changelog or any of that stuff. That will need to be done by a separate action. This creates a nice modularity boundary, in that this action doesn't care where the release came from (manual or another automated step)

Signed-off-by: Dorian Johnson <[email protected]>
  • Loading branch information
dorianj authored May 11, 2021
1 parent 0a4ce90 commit 19b842c
Showing 1 changed file with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,40 @@
name: Publish Release
name: Publish Release to PyPi
on:
push:
branches:
- master
paths:
# triggered when version is bumped
- "setup.py"
- "CHANGELOG.md"
jobs:
release:
types: [published]
jobs:
gather-info:
runs-on: ubuntu-latest
steps:
- name: Get module for release
id: module_folder
run: echo "::set-output name=module_folder::$(awk '{print $1}' << "${{ github.event.release.title }}")"
outputs:
module_folder: ${{ steps.module_folder.outputs.module_folder }}
push-to-pypi:
runs-on: ubuntu-latest
needs: gather-info
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Get version
id: vers
run: |
pip install python-semantic-release
echo ::set-output name=version::$(semantic-release print-version --current)
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.vers.outputs.version }}
release_name: New Features & Bug Fixes
body_path: ./CHANGELOG.md
- name: Add wheel dependency
run: pip install wheel
- name: Generate dist
run: python setup.py sdist bdist_wheel
working-directory: ${{ needs.gather-info.outputs.module_folder }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
packages_dir: ${{ needs.gather-info.outputs.module_folder }}/dist
build-and-publish-docker-image:
name: Build and publish docker image
needs: gather-info
runs-on: ubuntu-18.04
steps:
- name: Checkout
Expand All @@ -51,5 +44,7 @@ jobs:
- name: Publish to Registry for latest
if: success()
run: make build-push-image-latest
working-directory: ${{ needs.gather-info.outputs.module_folder }}
- name: Publish to Registry for version
run: make build-push-image-version
working-directory: ${{ needs.gather-info.outputs.module_folder }}

0 comments on commit 19b842c

Please sign in to comment.