Skip to content

[pre-commit.ci] pre-commit autoupdate #89

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #89

Workflow file for this run

name: Test, Build, and Publish
on:
push:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
dry_run:
type: boolean
description: 'Do not actually release the package, just check that it is valid.'
required: false
default: false
jobs:
run-tests:
uses: ./.github/workflows/test.yml
with:
debug_enabled: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
secrets: inherit
check-tag:
needs:
- run-tests
runs-on: ubuntu-latest
outputs:
tag-matches-version: ${{ steps.check-tag.outputs.tag-matches-version }}
fail-reason: ${{ steps.check-tag.outputs.fail-reason }}
steps:
- uses: actions/checkout@v4
- name: Install hatch
run: |
python -m pip install hatch
- name: Check tag matches version
id: check-tag
run: |
# Check if the tag matches the version or the version with a 'v' prefix
tag="$(git tag --points-at HEAD)"
# validate tag
if [[ "$tag" == "" || "$tag" == "v" || "$tag" == "vv"* ]]; then
echo "tag-matches-version=false" >> $GITHUB_OUTPUT
echo "fail-reason=tag not valid" >> $GITHUB_OUTPUT
exit 0
fi
hatch_version="$(hatch version)"
if [[ "$tag" == "v$hatch_version" || "$tag" == "$hatch_version" ]]; then
echo "tag-matches-version=true" >> $GITHUB_OUTPUT
else
echo "tag-matches-version=false" >> $GITHUB_OUTPUT
echo "fail-reason=v?tag != version" >> $GITHUB_OUTPUT
fi
publish-pypi:
runs-on: ubuntu-latest
needs:
- check-tag
if: github.event.inputs.dry-run != 'true' && needs.check-tag.outputs.tag-matches-version == 'true'
environment:
name: pypi
url: https://pypi.org/p/galv-harvester
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Install hatch
run: |
python -m pip install hatch
- name: Build dist
run: hatch run +py=3.11 build
- name: Publish 🐍 📦 to PyPI
# run if not dry-run AND we're pushing to a tag
uses: pypa/gh-action-pypi-publish@release/v1
publish-testpypi:
runs-on: ubuntu-latest
needs:
- check-tag
if: github.event.inputs.dry-run == 'true' || needs.check-tag.outputs.tag-matches-version != 'true'
environment:
name: testpypi
url: https://test.pypi.org/p/galv-harvester
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Install hatch
run: |
python -m pip install hatch
- name: Build dist
run: hatch run +py=3.11 build
- name: Publish 🐍 📦 to TestPyPI (dry-run)
if: github.event.inputs.dry-run == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish 🐍 📦 to TestPyPI (${{ steps.check-tag.outputs.fail-reason }})
if: github.event.inputs.dry-run != 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true