Skip to content

Commit

Permalink
Build + publish on Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
kousu committed Apr 20, 2022
1 parent 42e552f commit 7288ffe
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ref: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Publish Package

on:
# publish from the Releases page:
release:
types: [published]

# publish from the Actions page:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true

jobs:
publish:
name: Publish Package

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Create given tag
# because we use setuptools_scm, the tag needs to exist before running `build`
# this is a bit redundant because softprops/action-gh-release will recreate the
# same tag, on github
if: github.event.inputs.version
run: |
git tag -f "${{ github.event.inputs.version }}"
- uses: actions/setup-python@v3

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build
run: |
python -m build
- name: Publish to Github
uses: softprops/action-gh-release@v1
with:
files: 'dist/*'
fail_on_unmatched_files: true
tag_name: ${{ github.event.inputs.version }} # in the workflow_dispatch case, make a new tag from the given input; in the published release case, this will be empty and will fall back to updating that release.

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

0 comments on commit 7288ffe

Please sign in to comment.