Skip to content

Merge pull request #4 from chatbotkit/next #1

Merge pull request #4 from chatbotkit/next

Merge pull request #4 from chatbotkit/next #1

Workflow file for this run

# Auto-tag when merging to main
#
# Reads the version from pyproject.toml and, if the matching tag does not
# already exist, creates and pushes it, then triggers the release workflow
# (build + publish to PyPI + GitHub Release).
name: Tag Release
on:
push:
branches:
- main
permissions:
contents: write
actions: write
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from pyproject.toml
id: version
run: |
VERSION=$(grep -m1 '^version = ' pyproject.toml | sed -E 's/^version = "(.*)"/\1/')
if [ -z "$VERSION" ]; then
echo "Could not read version from pyproject.toml" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version: $VERSION"
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag v${{ steps.version.outputs.version }} already exists"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Tag v${{ steps.version.outputs.version }} does not exist"
fi
- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"
- name: Trigger release workflow
if: steps.check_tag.outputs.exists == 'false'
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'release.yml',
ref: 'v${{ steps.version.outputs.version }}'
})