Skip to content

release version

release version #92

name: release version
on:
workflow_run:
workflows: ["validate tests"]
types:
- completed
branches:
- master
permissions:
contents: write
jobs:
release-version:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: checkout code
uses: actions/checkout@v4
- name: get version
id: get-version
run: |
VERSION=$(python -c "import re; content=open('setup.py').read(); print(re.search(r'version=\"([^\"]+)\"', content).group(1))")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"
- name: check if tag exists
run: |
TAG="${{ steps.get-version.outputs.tag }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "❌ Tag $TAG already exists"
exit 1
fi
echo "✅ Tag $TAG does not exist, proceeding with release"
- name: check if release exists
run: |
TAG="${{ steps.get-version.outputs.tag }}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "❌ Release $TAG already exists"
exit 1
fi
echo "✅ Release $TAG does not exist, proceeding with release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create tag
run: |
TAG="${{ steps.get-version.outputs.tag }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release version ${{ steps.get-version.outputs.version }}"
git push origin "$TAG"
echo "✅ Created tag: $TAG"
- name: create github Release
run: |
TAG="${{ steps.get-version.outputs.tag }}"
VERSION="${{ steps.get-version.outputs.version }}"
gh release create "$TAG" \
--title "Release $VERSION" \
--notes "Automated release for version $VERSION" \
--latest
echo "✅ Created GitHub release: $TAG"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}