Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Feb 19, 2024
1 parent 44ada6e commit 9de1780
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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 commit -am '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 }}"

0 comments on commit 9de1780

Please sign in to comment.