Version Update and Release #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version Update and Release | |
# Workflow Process Flow: | |
# 1. Trigger Conditions: | |
# - Manual execution (workflow_dispatch) | |
# 2. Environment Setup (Ubuntu, Python, Poetry) | |
# 3. Retrieve the current version | |
# 4. Update to the new version (patch, minor, or major) | |
# 5. Commit and push the changes | |
# 6. Create and push a new tag | |
# 7. Generate the changelog | |
# 8. Create a GitHub release | |
on: | |
workflow_dispatch: | |
inputs: | |
update_type: | |
description: 'Type of version update' | |
required: true | |
default: 'patch' | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
update-version-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT_FOR_PUSHES }} | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: '3.12' | |
- name: Install poetry | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
- name: Get current version | |
id: current_version | |
run: echo "version=$(poetry version -s)" >> "$GITHUB_OUTPUT" | |
- name: Update version | |
id: update_version | |
run: | | |
poetry version ${{ github.event.inputs.update_type }} | |
echo "new_version=$(poetry version -s)" >> "$GITHUB_OUTPUT" | |
- name: Commit and push if changed | |
run: | | |
git add pyproject.toml | |
git commit -m ":wrench:Bump version to ${{ steps.update_version.outputs.new_version }}" || echo "No changes to commit" | |
git push | |
- name: Create and push new tag | |
run: | | |
git tag v${{ steps.update_version.outputs.new_version }} | |
git push --tags | |
- name: Generate changelog | |
id: changelog | |
run: | | |
changelog=$(git log --pretty=format:"- %s" v${{ steps.current_version.outputs.version }}..v${{ steps.update_version.outputs.new_version }}) | |
{ | |
echo "changelog<<EOF" | |
echo "$changelog" | |
echo "EOF" | |
} >> "$GITHUB_OUTPUT" | |
- name: Create Release | |
uses: softprops/[email protected] | |
with: | |
tag_name: v${{ steps.update_version.outputs.new_version }} | |
name: repo-dispatch-event-sender-v${{ steps.update_version.outputs.new_version }} | |
body: | | |
Changes in this Release: | |
${{ steps.changelog.outputs.changelog }} | |
For full changes, see the [comparison view](${{ github.server_url }}/${{ github.repository }}/compare/v${{ steps.current_version.outputs.version }}..v${{ steps.update_version.outputs.new_version }}) | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_FOR_PUSHES }} |