From b4b0e9145075d30e3c06258756541ffac5de4766 Mon Sep 17 00:00:00 2001 From: Artur Borecki Date: Sat, 2 Aug 2025 15:41:34 +0200 Subject: [PATCH] ci(release.yaml): add release workflow --- .github/workflows/release.yaml | 121 +++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..9a0a8b9 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,121 @@ +name: Bump version + +on: + workflow_dispatch: + inputs: + short_description: + type: string + description: 'Short description of the release' + required: false + auto_bump: + type: boolean + description: 'Auto bump version?' + required: true + bump_type: + type: choice + description: 'Bump type' + required: true + options: + - 'major' + - 'minor' + - 'patch' + - 'prerelease' + as_pre_release: + type: boolean + description: 'As pre-release?' + required: true + prerelease_type: + type: choice + description: 'Pre-release label' + required: true + options: + - 'dev' + - 'alpha' + - 'beta' + - 'rc' + - 'post' +jobs: + bump_version: + runs-on: ubuntu-latest + name: Bump version and create release + steps: + - name: ๐Ÿ”€ checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: "${{ secrets.GITHUB_TOKEN }}" + submodules: 'recursive' + + - name: ๐Ÿ“ฆ install uv + uses: astral-sh/setup-uv@v5 + + - name: ๐Ÿ python + uses: actions/setup-python@v5 + with: + python-version-file: "pyproject.toml" + + - name: ๐Ÿ“ฆ sync depedencies + run: | + uv sync + uv sync --group bump + + - name: configure git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: ๐Ÿ“ฆ bump version (auto) + if: ${{ github.event.inputs.auto_bump == 'true' }} + run: | + if [ "${{ github.event.inputs.as_pre_release }}" == "true" ]; then + uv run semantic-release version --no-changelog --no-commit --no-push --as-prerelease --prerelease-token ${{ github.event.inputs.prerelease_type }} + else + uv run semantic-release version --no-changelog --no-commit --no-push + fi + + - name: ๐Ÿ“ฆ bump version (manual) + if: ${{ github.event.inputs.auto_bump == 'false' }} + run: | + if [ "${{ github.event.inputs.as_pre_release }}" == "true" ]; then + uv run semantic-release version --no-changelog --no-commit --no-push --${{ github.event.inputs.bump_type }} --as-prerelease --prerelease-token ${{ github.event.inputs.prerelease_type }} + else + uv run semantic-release version --no-changelog --no-commit --no-push --${{ github.event.inputs.bump_type }} + fi + + - name: ๐Ÿ“ฆ get new version + id: get_version + run: echo "BUMPED_VERSION=$(cat pyproject.toml | grep -e "^version = " | cut -d '"' -f 2)" >> $GITHUB_OUTPUT + + - name: ๐Ÿ“ create changelog + run: | + uv run git-cliff -s header -l > release_body.md + echo "Changes:" && cat release_body.md + uv run git-cliff > CHANGELOG.md + + - name: ๐Ÿ“ค push changes + run: | + git add CHANGELOG.md pyproject.toml src/*/__init__.py + git commit -m "chore(release): ${{ steps.get_version.outputs.BUMPED_VERSION }}" + git push origin main + + - name: create release + uses: softprops/action-gh-release@v2 + with: + name: ${{ github.event.repository.name }} ${{ steps.get_version.outputs.BUMPED_VERSION }} - ${{ github.event.inputs.short_description }} + tag_name: ${{ steps.get_version.outputs.BUMPED_VERSION }} + body_path: release_body.md + prerelease: ${{ github.event.inputs.as_pre_release }} + discussion_category_name: 'Announcements' + + - name: ๐Ÿงน cleanup + run: | + rm release_body.md + + - name: ๐Ÿ“ค merge into develop + run: | + git checkout develop + git merge main + git push origin develop + + - name: โœ… done + run: echo "done"