Version and Release #8
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
on: | |
workflow_dispatch: # this is required to manually run workflows; it is terribly named | |
inputs: | |
new-version: | |
description: The new version; e.g. '1.0.0'. | |
required: true | |
name: Version and Release | |
jobs: | |
version-and-release: | |
name: Version and Release | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Checkout latest | |
uses: actions/checkout@v4 | |
- name: Update pyproject.toml version | |
id: update-version | |
run: | | |
NEW_VERSION=${{ github.event.inputs.new-version }} | |
sed -i "s/^version\s*=.*/version = \"$NEW_VERSION\"/" pyproject.toml | |
cat pyproject.toml | |
git add . | |
git commit -m "updated pyproject.toml version" | |
git push | |
echo "VERSION=$THIS_VERSION" >> $GITHUB_OUTPUT | |
- name: Create GitHub release | |
uses: elgohr/Github-Release-Action@v5 | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
title: ${{ steps.update-version.outputs.VERSION }}" | |
- name: Checkout latest since pyproject.toml update | |
uses: actions/checkout@v4 | |
with: | |
ref: "HEAD^" | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: python -m build | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1.8 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |