topen/.github/workflows/release.yaml
Marty Oehme 4ecf3627d3
Some checks failed
website / build (push) Has been cancelled
website / deploy (push) Has been cancelled
ref: Require github release to publish to pypi
2025-04-10 09:33:19 +02:00

96 lines
2.4 KiB
YAML

name: Publish release packages
on:
push:
tags:
- v*
jobs:
build:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
- name: Build the wheel and source tarball
run: uv build
- name: Store dist packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
create-release:
name: Create github release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Grab dist files
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Generate release
uses: taiki-e/create-gh-release-action@v1
with:
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
- name: Attach files to release
uses: softprops/action-gh-release@v2
with:
files: dist/*
publish-to-testpypi:
name: Test publishing to testpypi
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- create-release # use github release as sanity check for releases
environment:
name: testpypi
url: https://test.pypi.org/p/topen
permissions:
id-token: write
steps:
- name: Grab dist files
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Send off to TestPyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish dist to pypi
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- create-release
environment:
name: pypi
url: https://pypi.org/p/topen
permissions:
id-token: write
steps:
- name: Grab dist files
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Send off to PyPi
uses: pypa/gh-action-pypi-publish@release/v1