Skip to content

Commit

Permalink
Add PyPI publication GH workflow
Browse files Browse the repository at this point in the history
I've added a `publish.yaml` to publish `recap-core` via Github actions.

Recap is automatically published when a Github release is cut using the git tag
format `n.n.n` (semver). The GH action will automatically publish the package,
increment the version number in pyproject.toml, and commit the change. The patch
version is always incremented.

I followed the instructions here:

https://pdm.fming.dev/latest/usage/publish/#publish-with-trusted-publishers
https://docs.pypi.org/trusted-publishers/adding-a-publisher/
  • Loading branch information
criccomini committed Sep 1, 2023
1 parent 8dd5a0d commit 878e000
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: '3.10'

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install TOML CLI
run: cargo install toml-cli

- name: Publish to PyPI
run: pdm publish

- name: Bump version
run: |
TAG_NAME=${{ github.ref }}
TAG_NAME=${TAG_NAME#refs/tags/}
NEW_VERSION=$(echo $TAG_NAME | awk -F. '{$NF++; print $1"."$2"."$NF}')
toml set pyproject.toml project.version "$NEW_VERSION"
- name: Commit version bump
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Bump version
file_pattern: pyproject.toml

0 comments on commit 878e000

Please sign in to comment.