Skip to content

Commit

Permalink
Release flow/update (#43)
Browse files Browse the repository at this point in the history
Using GH action and bumpver to release the new version.
  • Loading branch information
unkcpz authored Nov 15, 2022
1 parent 60c17dd commit da9dcde
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
name: Publish on Test PyPI and PyPI

on:
push:
branches:
# Commits pushed to release/ branches are published on Test PyPI if they
# have a new version number.
- release/**
tags:
# Tags that start with the "v" prefix are published on PyPI.
- v*

jobs:

build:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install pypa/build
run: python -m pip install build

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Upload distribution artifact
uses: actions/upload-artifact@v2
with:
name: release
path: dist/

publish-test:

name: Build and publish on TestPyPI
if: >
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest

environment:
name: Test PyPI
url: https://test.pypi.org/project/widget-bandsplot/

steps:
- uses: actions/download-artifact@v2
name: Download distribution artifact
with:
name: release
path: dist/

- name: Publish distribution on Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/heads/release/')
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

publish:

name: Build and publish on PyPI
if: startsWith(github.ref, 'refs/tags')

needs: [build]
runs-on: ubuntu-latest

environment:
name: PyPI
url: https://pypi.org/project/widget-bandsplot/

steps:

- uses: actions/download-artifact@v2
name: Download distribution artifact
with:
name: release
path: dist/

- uses: softprops/[email protected]
name: Create release
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
dist/*
generate_release_notes: true

- name: Publish distribution on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ Then you need to rebuild the JS when you make a code change:

You then need to refresh the JupyterLab page when your javascript changes.

## For maintainers

To create a new release, clone the repository, install development dependencies with `pip install -e '.[dev]'`, and then execute `bumpver update [--major|--minor|--patch] [--tag [alpha|beta|rc]]`.
This will:

1. Create a tagged release with bumped version and push it to the repository.
2. Trigger a GitHub actions workflow that creates a GitHub release and publishes it on PyPI.

Additional notes:

- Use the `--dry` option to preview the release change.
- The release tag (e.g. a/b/rc) is determined from the last release.
Use the `--tag` option to switch the release tag.
- This packages follows semantic versioning.

## Acknowledgements

Expand Down

0 comments on commit da9dcde

Please sign in to comment.