Merge pull request 'feat: update release workflow to auto create release based on PR [skip-ci]' (#22) from dev into main
Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
@@ -18,12 +18,39 @@ on:
|
|||||||
- "major"
|
- "major"
|
||||||
- "minor"
|
- "minor"
|
||||||
- "patch"
|
- "patch"
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# Only run on merged PRs with [release-*] or manual workflow_dispatch
|
||||||
|
if: |
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.title, '[release-'))
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Determine bump type
|
||||||
|
id: bump_type
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||||
|
echo "type=${{ github.event.inputs.bump }}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
# Extract bump type from PR title: [release-patch], [release-minor], [release-major]
|
||||||
|
PR_TITLE="${{ github.event.pull_request.title }}"
|
||||||
|
if [[ "$PR_TITLE" =~ \[release-major\] ]]; then
|
||||||
|
echo "type=major" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "$PR_TITLE" =~ \[release-minor\] ]]; then
|
||||||
|
echo "type=minor" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "$PR_TITLE" =~ \[release-patch\] ]]; then
|
||||||
|
echo "type=patch" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "type=patch" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4.2.2
|
uses: actions/checkout@v4.2.2
|
||||||
with:
|
with:
|
||||||
@@ -52,7 +79,7 @@ jobs:
|
|||||||
id: bump
|
id: bump
|
||||||
run: |
|
run: |
|
||||||
uv tool install bump-my-version
|
uv tool install bump-my-version
|
||||||
uv tool run bump-my-version bump ${{ github.event.inputs.bump }}
|
uv tool run bump-my-version bump ${{ steps.bump_type.outputs.type }}
|
||||||
# echo the version to github env, the version is shown by using uv tool run bump-my-version show current_version
|
# 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 "VERSION<<EOF" >> $GITHUB_ENV
|
||||||
echo "$(uv tool run bump-my-version show current_version)" >> $GITHUB_ENV
|
echo "$(uv tool run bump-my-version show current_version)" >> $GITHUB_ENV
|
||||||
@@ -82,7 +109,7 @@ jobs:
|
|||||||
echo "IMAGE_REPO=${{ secrets.REGISTRY }}/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
echo "IMAGE_REPO=${{ secrets.REGISTRY }}/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
if: ${{ github.event.inputs.docker_release == 'true' }}
|
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.docker_release == 'true' || github.event_name == 'pull_request' }}
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -92,7 +119,7 @@ jobs:
|
|||||||
type=raw,value=${{ env.VERSION }}
|
type=raw,value=${{ env.VERSION }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
if: ${{ github.event.inputs.docker_release == 'true' }}
|
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.docker_release == 'true' || github.event_name == 'pull_request' }}
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -118,7 +145,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
if: ${{ github.event.inputs.github_release == 'true' }}
|
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.github_release == 'true' || github.event_name == 'pull_request' }}
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ env.VERSION }}
|
tag_name: v${{ env.VERSION }}
|
||||||
|
|||||||
Reference in New Issue
Block a user