kwork-api/.gitea/workflows/release.yml
root 0634262eb2
Some checks failed
PR Checks / test (pull_request) Failing after 10s
PR Checks / security (pull_request) Failing after 6s
ci: rename secret from GITEA_TOKEN to CI_TOKEN
Gitea secrets cannot start with GITEA_ or GITHUB_ prefix.
2026-03-29 01:13:59 +00:00

125 lines
3.5 KiB
YAML

name: Release & Publish
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
on:
push:
branches: [main]
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
semantic-release:
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
outputs:
new_release_version: ${{ steps.semantic.outputs['new_release_version'] }}
new_release_published: ${{ steps.semantic.outputs['new_release_published'] }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITEA_TOKEN }}
- name: Use system Python
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: uv sync --group dev
- name: Run semantic-release
id: semantic
env:
GH_TOKEN: ${{ secrets.GITEA_TOKEN }}
GIT_AUTHOR_NAME: claw-bot
GIT_AUTHOR_EMAIL: claw-bot@much-data.ru
GIT_COMMITTER_NAME: claw-bot
GIT_COMMITTER_EMAIL: claw-bot@much-data.ru
run: |
uv run semantic-release version --no-push
NEW_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "new_release_version=$NEW_VERSION" >> $GITHUB_OUTPUT
# Check if version changed
if git diff --quiet pyproject.toml; then
echo "new_release_published=false" >> $GITHUB_OUTPUT
else
echo "new_release_published=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push version bump
if: steps.semantic.outputs.new_release_published == 'true'
run: |
uv run semantic-release changelog
git add pyproject.toml CHANGELOG.md
git commit -m "chore(release): v${{ steps.semantic.outputs.new_release_version }} [skip ci]"
git tag v${{ steps.semantic.outputs.new_release_version }}
git push origin main --tags
build:
runs-on: ubuntu-latest
timeout-minutes: 15
if: github.ref == 'refs/tags/v*'
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use system Python
run: |
echo "Python $(python3 --version)"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install dependencies (production only)
run: uv sync --no-dev
- name: Build package
run: uv build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
retention-days: 7
publish-gitea:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Publish to Gitea Packages
run: |
uv publish \
--username ${{ github.actor }} \
--password ${{ env.GITEA_TOKEN }} \
https://git.much-data.ru/api/packages/${{ github.repository_owner }}/pypi