diff --git a/.github/workflows/bump-version-v2.yaml b/.github/workflows/bump-version-v2.yaml new file mode 100644 index 000000000..9bb0c18ea --- /dev/null +++ b/.github/workflows/bump-version-v2.yaml @@ -0,0 +1,69 @@ +name: Bump version and changelog v2 +on: + push: + + +jobs: + bumpversion: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + version: 1.0.1 + previous_tag: ${{ steps.tag_version.outputs.previous_tag }} + bump_commit_sha: ${{ steps.bumpversion.outputs.commit_hash }} + pr_number: ${{ steps.cpr.outputs.pull-request-number }} + steps: + - uses: actions/checkout@v4 + - name: Get next version + id: tag_version + uses: mathieudutour/github-tag-action@v6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + default_bump: 1.0.1 + default_prerelease_bump: false + dry_run: true + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Create bumpversion + run: | + pip install bump2version + bump2version --new-version 1.0.1 setup.cfg tutoraspects/__about__.py .ci/config.yml + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1.11.0 + with: + latest-version: 1.0.1 + release-notes: ${{ steps.tag_version.outputs.changelog }} + - name: Push branch + run: | + branch_name="bot/v1.0.1" + git fetch --prune origin + if git show-ref --quiet refs/remotes/origin/$branch_name; then + git push --delete origin $branch_name + fi + git checkout -b $branch_name || git checkout $branch_name + git push origin $branch_name + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} + title: "chore: preparing release 1.0.1" + commit-message: "chore: preparing release 1.0.1" + branch: "bot/v${{github.event.inputs.version}}" + base: main + body: | + Automated version bump for release 1.0.1. + + This pull request was automatically generated. It includes the following changes: + + - Version: 1.0.1 + - Previous version: ${{ steps.tag_version.outputs.previous_tag }} + + ${{ steps.tag_version.outputs.changelog }} + + No code changes are included in this pull request. The purpose of this PR is to trigger a version bump for the project. + + Once the pull request is merged, a new GitHub release will be created with the updated version. diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml index a57eb2a02..c66ba87e5 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version.yaml @@ -3,10 +3,14 @@ on: workflow_dispatch: inputs: version: - description: 'The version to release (e.g 1.2.3)' + description: 'The version to bump to' required: true - default: '' - type: string + default: 'minor' + type: choice + options: + - major + - minor + - patch jobs: @@ -15,7 +19,7 @@ jobs: permissions: contents: write outputs: - version: ${{ github.event.inputs.version }} + version: ${{ steps.tag_version.outputs.new_version }} previous_tag: ${{ steps.tag_version.outputs.previous_tag }} bump_commit_sha: ${{ steps.bumpversion.outputs.commit_hash }} pr_number: ${{ steps.cpr.outputs.pull-request-number }} @@ -34,20 +38,20 @@ jobs: with: python-version: "3.12" - name: Create bumpversion - if: github.event.inputs.version + if: steps.tag_version.outputs.new_version run: | pip install bump2version - bump2version --new-version ${{ github.event.inputs.version }} setup.cfg tutoraspects/__about__.py .ci/config.yml + bump2version --new-version ${{ steps.tag_version.outputs.new_version }} setup.cfg tutoraspects/__about__.py .ci/config.yml - name: Update Changelog - if: github.event.inputs.version + if: steps.tag_version.outputs.new_version uses: stefanzweifel/changelog-updater-action@v1.11.0 with: - latest-version: ${{ github.event.inputs.version }} + latest-version: ${{ steps.tag_version.outputs.new_tag }} release-notes: ${{ steps.tag_version.outputs.changelog }} - name: Push branch - if: github.event.inputs.version + if: steps.tag_version.outputs.new_version run: | - branch_name="bot/v${{ github.event.inputs.version }}" + branch_name="bot/v${{ steps.tag_version.outputs.new_version }}" git fetch --prune origin if git show-ref --quiet refs/remotes/origin/$branch_name; then git push --delete origin $branch_name @@ -55,20 +59,21 @@ jobs: git checkout -b $branch_name || git checkout $branch_name git push origin $branch_name - name: Create Pull Request + if: steps.tag_version.outputs.new_version id: cpr uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }} - title: "chore: preparing release ${{ github.event.inputs.version }}" - commit-message: "chore: preparing release ${{ github.event.inputs.version }}" - branch: "bot/v${{github.event.inputs.version}}" + title: "chore: preparing release ${{ steps.tag_version.outputs.new_version }}" + commit-message: "chore: preparing release ${{ steps.tag_version.outputs.new_version }}" + branch: "bot/v${{steps.tag_version.outputs.new_version}}" base: main body: | - Automated version bump for release ${{ github.event.inputs.version }}. + Automated version bump for release ${{ steps.tag_version.outputs.new_version }}. This pull request was automatically generated. It includes the following changes: - - Version: ${{ github.event.inputs.version }} + - Version: ${{ steps.tag_version.outputs.new_version }} - Previous version: ${{ steps.tag_version.outputs.previous_tag }} ${{ steps.tag_version.outputs.changelog }}