Skip to content

fix: conditional

fix: conditional #14

Workflow file for this run

# Build a project release whenever a pull request is merged to main.
---
name: Release
env:
# Current supported Python version. For applications, there is generally no
# reason to support multiple Python versions, so all actions are run with
# this version. Quote the version to avoid interpretation as a floating
# point number.
PYTHON_VERSION: "3.12"
UV_PYTHON_PREFERENCE: "system"
BUILDKIT_PROGRESS: "plain"
GIT_USERNAME: "github_actions[bot]"
GIT_USEREMAIL: "41898282+github_actions[bot]@users.noreply.github.com"
"on":
pull_request:
types:
- closed
branches:
- main
jobs:
# Release -- when PR is merged to main, bump version, make tag, recommit
release:
runs-on: ubuntu-latest
timeout-minutes: 10
if: >-
github.event_name == 'pull_request'
&& github.event.action == 'closed'
&& github.event.pull_request.merged == true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Force correct release branch
run: git checkout -B ${{ github.ref_name }} ${{ github.sha }}
# NOTE: PSR will create an incorrect tag with its default tag_format if there
# are no tags in the repository; seed the repo tag list with 0.0.0 to workaround
# this problem.
- name: Make Release
id: release
uses: python-semantic-release/[email protected]
with:
root_options: "-vv"
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: ${{ env.GIT_USERNAME }}
git_committer_email: ${{ env.GIT_USEREMAIL }}
build: false
changelog: false
vcs_release: false
# Pushing the tag will not trigger any related events, so we have to use
# workflow_dispatch to affect the tag-related build.
- name: Trigger Build Workflow
uses: actions/github-script@v7
if: >-
steps.release.outputs.released == true
env:
TAG_REF: ${{ steps.release.outputs.tag }}
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build.yaml',
ref: '${ process.env.TAG_REF }'
})