Skip to content

Commit

Permalink
Merge pull request #600 from alphagov/ldeb-add-publish-release-workflows
Browse files Browse the repository at this point in the history
Add GitHub workflows to release and publish package
  • Loading branch information
lfdebrux authored Feb 23, 2021
2 parents b67788f + 4c94081 commit 0946d16
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Upload a Python package to PyPI when a release is created
#
# For more information see:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python package to PyPI

on:
release:
types:
- published

jobs:
publish:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.6'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Create a release using the version number from the Python package
#
# This workflow is designed to create a GitHub release whenever a pull request
# is merged to the main branch that updates the version number for this repo's
# Python package.
#
# The release is created with the tag and name of the version number.
#
# If there already exists a tag for the package version number the release
# should not be created.

name: Create a GitHub release

on:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: '3.6'

- name: Get package version
id: package_version
run: echo "::set-output name=python::"$(python setup.py --version)

- name: Check if version tag already exists
id: version_tag
uses: mukunku/tag-exists-action@f8003af57c02ede2638326be67523df10cf6b10a
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ steps.package_version.outputs.python }}

- name: Create GitHub release
if: ${{ steps.version_tag.outputs.exists == 'false' }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.DM_GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package_version.outputs.python }}
release_name: Release v${{ steps.package_version.outputs.python }}

0 comments on commit 0946d16

Please sign in to comment.