Make Release #1
This file contains hidden or 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: Make Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: | | |
| Version bump type: | |
| - patch: 0.1.0 → 0.1.1 (bug fixes) | |
| - minor: 0.1.0 → 0.2.0 (new features, default) | |
| - major: 0.1.0 → 1.0.0 (breaking changes) | |
| required: true | |
| default: 'minor' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Get current version | |
| id: current | |
| run: | | |
| VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $VERSION" | |
| - name: Calculate new version | |
| id: new | |
| run: | | |
| CURRENT="${{ steps.current.outputs.version }}" | |
| BUMP="${{ inputs.bump }}" | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" | |
| case $BUMP in | |
| major) | |
| MAJOR=$((MAJOR + 1)) | |
| MINOR=0 | |
| PATCH=0 | |
| ;; | |
| minor) | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| ;; | |
| patch) | |
| PATCH=$((PATCH + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VERSION" | |
| - name: Update pyproject.toml | |
| run: | | |
| sed -i 's/^version = ".*"/version = "${{ steps.new.outputs.version }}"/' pyproject.toml | |
| echo "Updated pyproject.toml:" | |
| grep '^version' pyproject.toml | |
| - name: Commit and push | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add pyproject.toml | |
| git commit -m "Release v${{ steps.new.outputs.version }}" | |
| git push | |
| - name: Create and push tag | |
| run: | | |
| git tag "v${{ steps.new.outputs.version }}" | |
| git push origin "v${{ steps.new.outputs.version }}" | |
| echo "Created tag: v${{ steps.new.outputs.version }}" | |
| - name: Summary | |
| run: | | |
| echo "## Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Previous version:** v${{ steps.current.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **New version:** v${{ steps.new.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Bump type:** ${{ inputs.bump }}" >> $GITHUB_STEP_SUMMARY |