Merge pull request 'chore: add secondary release workflow based on commit messages' (#28) from dev into main
Reviewed-on: #28
This commit was merged in pull request #28.
This commit is contained in:
180
.gitea/workflows/release_with_commit_mode.yml
Normal file
180
.gitea/workflows/release_with_commit_mode.yml
Normal file
@@ -0,0 +1,180 @@
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
||||
github_release:
|
||||
description: 'Create Gitea Release'
|
||||
default: true
|
||||
type: boolean
|
||||
docker_release:
|
||||
description: 'Push Docker images'
|
||||
default: true
|
||||
type: boolean
|
||||
bump:
|
||||
description: 'Bump type'
|
||||
required: true
|
||||
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-tags: true
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.TOKEN }}
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
- name: Set up Python
|
||||
run: uv python install
|
||||
with:
|
||||
python-version-file: "pyproject.toml"
|
||||
|
||||
- name: Install the project
|
||||
run: uv sync --all-extras --dev
|
||||
|
||||
- name: Create requirements.txt
|
||||
run: |
|
||||
echo "Creating requirements.txt"
|
||||
uv export --format requirements.txt -o requirements.txt
|
||||
echo "requirements.txt created"
|
||||
|
||||
- name: Set Git identity
|
||||
run: |
|
||||
git config user.name "Gitea CI"
|
||||
git config user.email "ci@git.theprivateserver.de"
|
||||
- name: Get Repository URL
|
||||
id: get_repo_url
|
||||
run: echo "REPO_URL=https://github.com/${{ github.repository }}" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
- name: Build Changelog
|
||||
id: build_changelog
|
||||
uses: https://github.com/mikepenz/release-changelog-builder-action@v5
|
||||
with:
|
||||
platform: "gitea"
|
||||
mode: "COMMIT"
|
||||
baseURL: "http://gitea:3000"
|
||||
# configuration: ".gitea/changelog-config.json"
|
||||
configurationJSON: |
|
||||
{
|
||||
"template": "#{{CHANGELOG}}",
|
||||
"categories": [
|
||||
{
|
||||
"title": "## 🚀 Features",
|
||||
"labels": ["feat"]
|
||||
},
|
||||
{
|
||||
"title": "## 🐛 Fixes",
|
||||
"labels": ["fix", "bug"]
|
||||
},
|
||||
{
|
||||
"title": "## 🧹 Maintenance",
|
||||
"labels": ["chore", "refactor", "cleanup"]
|
||||
},
|
||||
{
|
||||
"title": "## 📦 Build",
|
||||
"labels": ["build", "ci"]
|
||||
},
|
||||
{
|
||||
"title": "## 📝 Documentation",
|
||||
"labels": ["docs"]
|
||||
},
|
||||
{
|
||||
"title": "## ⚡️ Performance Improvements",
|
||||
"labels": ["perf"]
|
||||
},
|
||||
{
|
||||
"title": "## 🧪 Tests",
|
||||
"labels": ["test"]
|
||||
},
|
||||
{
|
||||
"title": "## ⏪ Reverts",
|
||||
"labels": ["revert"]
|
||||
},
|
||||
{
|
||||
"title": "## 🎨 Styling",
|
||||
"labels": ["style"]
|
||||
},
|
||||
{
|
||||
"title": "## 🎯 Other Changes",
|
||||
"labels": ["other", "misc", "enhancement"]
|
||||
}
|
||||
],
|
||||
"label_extractor": [
|
||||
{
|
||||
"pattern": "^(build|chore|ci|docs|feat|fix|bug|perf|cleanup|refactor|revert|style|test){1}(\\([\\w\\-\\.]+\\))?(!)?: ([\\w ])+([\\s\\S]*)",
|
||||
"target": "$1"
|
||||
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
"empty_template": "- no changes",
|
||||
"pr_template": "- [#{{TITLE}}](${{ steps.get_repo_url.outputs.REPO_URL }}/commit/#{{MERGE_SHA}}) by @#{{AUTHOR}}"
|
||||
}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
|
||||
- name: Bump version
|
||||
id: bump
|
||||
run: |
|
||||
uv tool install bump-my-version
|
||||
uv tool run bump-my-version bump ${{ github.event.inputs.bump }} --allow-dirty
|
||||
# echo the version to github env, the version is shown by using uv tool run bump-my-version show current_version
|
||||
echo "VERSION<<EOF" >> $GITHUB_ENV
|
||||
echo "$(uv tool run bump-my-version show current_version)" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
- name: Check version
|
||||
run: echo ${{ env.VERSION }}
|
||||
- name: Build and store Docker image
|
||||
if: ${{ github.event.inputs.docker_release == 'true' }}
|
||||
run: |
|
||||
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--tag ${{ secrets.REGISTRY }}/${REPO_NAME}:latest \
|
||||
--tag ${{ secrets.REGISTRY }}/${REPO_NAME}:${{ env.VERSION }} \
|
||||
--push .
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
||||
- 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 ${{ env.VERSION }}
|
||||
body: ${{steps.build_changelog.outputs.changelog}}
|
||||
draft: false
|
||||
prerelease: false
|
||||
make_latest: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user