Skip to content

Improve workflow

Improve workflow #2

Workflow file for this run

# Automated release workflow
name: Create Release
on:
push:
branches: [ main ]
paths: [ 'pyproject.toml' ]
jobs:
ci:
uses: ./.github/workflows/ci.yml

Check failure on line 11 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

error parsing called workflow ".github/workflows/release.yml" -> "./.github/workflows/ci.yml" (source branch with sha:797295204aca9df9e4ed49bb53ff00cd6d6f2cd6) : workflow is not reusable as it is missing a `on.workflow_call` trigger
check-version:
needs: ci
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_changed: ${{ steps.version.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Extract version from pyproject.toml
id: version
run: |
# Get current version from pyproject.toml using grep and sed
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Check if this version already has a tag
if git tag -l | grep -q "^v$CURRENT_VERSION$"; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "Version v$CURRENT_VERSION already exists as a tag"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "New version detected: v$CURRENT_VERSION"
fi
create-release:
needs: check-version
if: needs.check-version.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create git tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag ${{ needs.check-version.outputs.version }}
git push origin ${{ needs.check-version.outputs.version }}
- name: Create GitHub Release
run: |
gh release create ${{ needs.check-version.outputs.version }} \
--title "${{ needs.check-version.outputs.version }}" \
--notes "Release ${{ needs.check-version.outputs.version }}
Auto-generated release from version bump in pyproject.toml"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python for publishing
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}