Skip to content

Test pyproject update #1

Test pyproject update

Test pyproject update #1

Workflow file for this run

name: Check for publishing
on:
push:
branches:
- 'pyproject_trigger'
paths:
- 'pyproject.toml'
jobs:
check_publish:
name: "Check if we should publish"
runs-on: ubuntu-latest
outputs:
version_result: ${{ steps.check_pyproject_toml.outputs.new_tag }}
steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: "Setup Python"
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.x"
- name: "Check pyproject.toml for a new version"
id: check_pyproject_toml
run: |
cd ./publish && echo "new_tag=$(python3 read_pyproject.py)" >> $GITHUB_OUTPUT
fail_if_output_minus_one:
name: "Fail the job if the publish check returns '-1'"
runs-on: ubuntu-latest
needs: check_publish
if: needs.check_publish.outputs.version_result == '-1'
steps:
- run: |
echo "Job failed, the check_publish returned '-1'" && exit 1
do_nothing_if_output_zero:
name: "Do nothing if the publish check returns '0'"
runs-on: ubuntu-latest
needs: check_publish
if: needs.check_publish.outputs.version_result == '0'
steps:
- run: |
echo "Nothing to do, no new version exists" && exit 0
create_new_tag_if_output_tag:
name: "Create a new tag if the publish check returns a tag"
runs-on: ubuntu-latest
needs: check_publish
if: needs.check_publish.outputs.version_result != '0' && needs.check_publish.outputs.version_result != '-1'
steps:
- name: "Checkout repository"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Create tag
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
result-encoding: string
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{needs.check_publish.outputs.version_result}}',
sha: context.sha
})