From 8214cc85ceb2148a1cf340194c059056ff122d68 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Mon, 13 Oct 2025 14:37:14 +0200 Subject: [PATCH] add workflow to create package --- .gitea/changelog_config.json | 114 +++++++++++++++++++++++++ .gitea/workflows/build_and_publish.yml | 84 ++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 .gitea/changelog_config.json create mode 100644 .gitea/workflows/build_and_publish.yml diff --git a/.gitea/changelog_config.json b/.gitea/changelog_config.json new file mode 100644 index 0000000..88b580b --- /dev/null +++ b/.gitea/changelog_config.json @@ -0,0 +1,114 @@ +{ + "categories": [ + { + "title": "## ๐Ÿš€ Features", + "labels": [ + "add", + "Add", + "Kind/Feature", + "feat", + "Feature", + "Feat" + ] + }, + { + "title": "## ๐Ÿงฐ Enhancements", + "labels": [ + "enhancement", + "Enhancement", + "Kind/Enhancement", + "improvement", + "Improvement", + "Kind/Improvement" + ] + }, + { + "title": "## ๐Ÿ› Fixes", + "labels": [ + "fix", + "Fix", + "Kind/Bug", + "Kind/Security" + ] + }, + { + "title": "## ๐Ÿงช Upgrade", + "labels": [ + "upgrade", + "Upgrade", + "Clean" + ] + }, + { + "title": "## ๐Ÿ“ Documentation", + "labels": [ + "docs", + "Docs", + "Kind/Documentation" + ] + }, + { + "title": "## ๐Ÿ› ๏ธ Maintenance", + "labels": [ + "maintenance", + "Maintenance", + "Kind/Maintenance", + "chore", + "Chore", + "Kind/Chore" + ] + }, + { + "title": "## โช Reverts", + "labels": [ + "revert", + "Revert", + "Kind/Revert", + "Kind/Reverts", + "reverts", + "Reverts" + ] + }, + { + "title": "## ๐Ÿ—‘๏ธ Deprecation", + "labels": [ + "deprecation", + "Deprecation", + "Kind/Deprecation" + ] + }, + { + "title": "## โšก๏ธ Performance Improvements", + "labels": [ + "perf", + "Perf", + "Kind/Performance" + ] + }, + { + "title": "## ๐ŸŽจ Styling", + "labels": [ + "style", + "Style", + "Kind/Style" + ] + }, + { + "title": "## ๐ŸŽฏ Other Changes", + "labels": [] + } + ], + "label_extractor": [ + { + "pattern": "(\\w+) (.+)", + "target": "$1", + "on_property": "title" + } + ], + "sort": "ASC", + "template": "${{CHANGELOG}}", + "pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}", + "empty_template": "- no changes", + "max_pull_requests": 1000, + "max_back_track_time_days": 1000 +} \ No newline at end of file diff --git a/.gitea/workflows/build_and_publish.yml b/.gitea/workflows/build_and_publish.yml new file mode 100644 index 0000000..9272b10 --- /dev/null +++ b/.gitea/workflows/build_and_publish.yml @@ -0,0 +1,84 @@ +on: + workflow_dispatch: + inputs: + github_release: + description: 'Create Gitea Release' + default: true + type: boolean + bump: + description: 'Bump type' + required: false + default: 'patch' + type: choice + options: + - 'major' + - 'minor' + - 'patch' +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@master + with: + fetch-depth: 0 # Fetch full history + fetch-tags: true # Fetch all tags (refs/tags) + + - name: Install uv + uses: astral-sh/setup-uv@v5 + - name: Set up Python + run: uv python install + with: + python-version-file: "pyproject.toml" + - name: Set Git identity + run: | + git config user.name "Gitea CI" + git config user.email "ci@git.theprivateserver.de" + - name: Bump version + id: bump + run: | + uv tool install bump-my-version + uv tool run bump-my-version bump ${{ github.event.inputs.bump }} + # echo the version to github env, the version is shown by using uv tool run bump-my-version show current_version + echo "VERSION<> $GITHUB_ENV + echo "$(uv tool run bump-my-version show current_version)" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + - name: Build Changelog + id: build_changelog + uses: https://github.com/mikepenz/release-changelog-builder-action@v5 + with: + platform: "gitea" + baseURL: "http://gitea:3000" + configuration: ".gitea/changelog_config.json" + + env: + GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} + - name: Build package + run: uv build + - name: Publish package + env: + USERNAME: ${{ github.repository_owner }} + run: uv publish --publish-url https://git.theprivateserver.de/api/packages/$USERNAME/pypi/ -t ${{ secrets.TOKEN }} + + + - name: Create release + id: create_release + if: ${{ github.event.inputs.github_release == 'true' }} + uses: softprops/action-gh-release@master + with: + tag_name: v${{ env.VERSION }} + release_name: Release v${{ env.VERSION }} + body: ${{steps.build_changelog.outputs.changelog}} + draft: false + prerelease: false + make_latest: true + files: | + dist/* + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} \ No newline at end of file