Publish release #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'New version number' | |
required: true | |
jobs: | |
build: | |
if: contains('["chrispyles"]', github.actor) | |
runs-on: ubuntu-latest | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
steps: | |
- name: Only allow releases off of main | |
run: | | |
python3 -c 'import os, sys; sys.exit(os.environ["GITHUB_REF"] != "refs/heads/main")' | |
- uses: actions/checkout@v2 | |
- uses: getsentry/[email protected] | |
with: | |
python-version: 3.11 | |
cache-dependency-path: | | |
requirements.txt | |
requirements-dev.txt | |
install-cmd: pip install -r requirements.txt -r requirements-dev.txt twine wheel setuptools | |
- name: Update versions | |
run: | | |
echo "__version__ = \"${{ github.event.inputs.version }}\"" > nbforms/version.py | |
- name: Commit and push | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -b release | |
git add nbforms/version.py | |
git commit -m 'release v${{ github.event.inputs.version }}' | |
git push --set-upstream origin release | |
- name: Create dist and push to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
python3 setup.py sdist bdist_wheel | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Create a release on GitHub | |
env: | |
GITHUB_USER: ${{ secrets.GITHUB_USER }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create \ | |
--title 'v${{ github.event.inputs.version }}' \ | |
--target release \ | |
'v${{ github.event.inputs.version }}' \ | |
dist/*.tar.gz \ | |
dist/*.whl | |
- name: Create a latest tag | |
run: | | |
git tag -f latest | |
git push --force origin latest | |
- name: PR release -> main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr create \ | |
--repo chrispyles/nbforms \ | |
--base master \ | |
--head chrispyles:release \ | |
--label "release" \ | |
--reviewer chrispyles \ | |
--milestone "v${{ github.event.inputs.version }}" \ | |
--title "Release v${{ github.event.inputs.version }}" \ | |
--body "Updates from the release of version ${{ github.event.inputs.version }}" |