Files
python-repositories/.gitea/workflows/release.yml
T
Brian Bjarke JensenandCursor b21fd247c5
PR Title Check / check-title (pull_request) Successful in 6s
Test Python Package / unit-tests (pull_request) Successful in 1m4s
Code Quality Pipeline / code-quality (pull_request) Successful in 1m48s
Test Python Package / integration-tests (pull_request) Successful in 2m10s
Test Python Package / coverage-report (pull_request) Successful in 20s
Revert workflows to ubuntu-latest until CI image is seeded.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-09 22:47:52 +02:00

84 lines
3.0 KiB
YAML

name: Release on merge to main
on:
push:
branches:
- main
jobs:
release:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.CI_RUNNER_TOKEN }}
- name: Parse merge commit
id: meta
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: scripts/ci/parse-merge-commit.sh "$COMMIT_MSG"
- name: Set up Python
if: steps.meta.outputs.bump != 'skip'
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install uv
if: steps.meta.outputs.bump != 'skip'
run: pip install uv
- name: Bump version
if: steps.meta.outputs.bump != 'skip'
id: bump
run: scripts/ci/bump-version.sh "${{ steps.meta.outputs.bump }}"
- name: Generate release notes
if: steps.meta.outputs.bump != 'skip'
id: notes
env:
PR_TITLE: ${{ steps.meta.outputs.pr_title }}
run: |
PREV_TAG=$(git describe --tags --abbrev=0)
NEW_TAG="v${{ steps.bump.outputs.version }}"
scripts/ci/generate-release-notes.sh "$NEW_TAG" "$PR_TITLE" "$PREV_TAG"
- name: Commit, tag, and push
if: steps.meta.outputs.bump != 'skip'
env:
VERSION: ${{ steps.bump.outputs.version }}
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: |
git config user.name "CI Bot"
git config user.email "ci-bot@example.com"
git add pyproject.toml uv.lock
git commit -m "chore: release v${VERSION} [skip ci]"
git tag "v${VERSION}"
git remote set-url origin "https://x-access-token:${CI_RUNNER_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
git push origin main
git push origin "v${VERSION}"
- name: Create Gitea release
if: steps.meta.outputs.bump != 'skip'
env:
API_URL: ${{ vars.API_URL }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
VERSION: ${{ steps.bump.outputs.version }}
PR_TITLE: ${{ steps.meta.outputs.pr_title }}
RELEASE_BODY: ${{ steps.notes.outputs.body }}
run: |
SUMMARY=$(echo "$PR_TITLE" | sed -E 's/^\[(patch|fix|minor|feat|major|breaking)\][[:space:]]*//i')
export RELEASE_NAME="v${VERSION} — ${SUMMARY}"
PAYLOAD=$(python3 -c 'import json, os; print(json.dumps({"tag_name": "v" + os.environ["VERSION"], "name": os.environ["RELEASE_NAME"], "body": os.environ["RELEASE_BODY"]}))')
curl -s -X POST \
"${API_URL}/repos/${REPO_OWNER}/${REPO_NAME}/releases" \
-H "Authorization: token ${CI_RUNNER_TOKEN}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"