Release #6
Workflow file for this run
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
target: | |
default: testpypi | |
description: Deployment target. Can be pypi or testpypi. | |
release: | |
types: | |
- published | |
jobs: | |
dist: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Replace stable version with the release version | |
run: |- | |
# store the release tag | |
tag="${{ github.ref_name }}" | |
# files to search for | |
md_rst_files=$(find . -type f \( -name "*.md" -o -name "*.rst" \)) | |
# regex patterns | |
badge_pattern="s#(readthedocs\.org/projects/glass/badge/\?version=)stable#\1${tag}#g" | |
url_pattern="s#(glass\.readthedocs\.io.*?)/stable#\1/${tag}#g" | |
# perform the replacements | |
for file in $md_rst_files; do | |
sed -E -i "$badge_pattern; $url_pattern" "$file" | |
done | |
- name: Build SDist and wheel | |
run: pipx run build | |
- name: Check metadata | |
run: pipx run twine check dist/* | |
- name: Upload distributions | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/* | |
publish: | |
needs: dist | |
runs-on: ubuntu-latest | |
environment: | |
name: publish | |
url: https://pypi.org/p/glass | |
permissions: | |
id-token: write | |
steps: | |
- name: Download distributions | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifact | |
path: dist | |
- name: List distributions to be deployed | |
run: ls -l dist/ | |
- name: Publish to PyPI | |
if: >- | |
github.event.inputs.target == 'pypi' || (github.event_name == | |
'release' && github.event.action == 'published') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Publish to TestPyPI | |
if: github.event.inputs.target == 'testpypi' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |