|
| 1 | +name: Display the version hint |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [synchronize] |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +jobs: |
| 8 | + bumpversion: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + with: |
| 13 | + fetch-depth: 0 |
| 14 | + token: ${{ secrets.PAT }} |
| 15 | + |
| 16 | + - uses: actions/setup-python@v4 |
| 17 | + with: |
| 18 | + python-version: '3.11' |
| 19 | + cache: 'pip' # caching pip dependencies |
| 20 | + |
| 21 | + - name: Install requirements |
| 22 | + run: | |
| 23 | + python -m pip install . bump-my-version |
| 24 | +
|
| 25 | + - name: Git check |
| 26 | + run: | |
| 27 | + git config --global user.email "no-reply@github.actions" |
| 28 | + git config --global user.name "Testing Git" |
| 29 | + git --version |
| 30 | + git config --list |
| 31 | +
|
| 32 | + - name: Get the release hint |
| 33 | + id: generate-changelog |
| 34 | + run: | |
| 35 | + RELEASE_KIND=$(generate-changelog --output release-hint --branch-override ${{ github.base_ref }} --skip-output-pipeline) |
| 36 | + echo "::notice::Suggested release type upon merge to ${{ github.base_ref }}: ${RELEASE_KIND}" |
| 37 | + echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV |
| 38 | + echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT |
| 39 | +
|
| 40 | + - name: Bump Version dry run |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + PR_NUMBER=$(gh pr view --json number -q .number || echo "") |
| 44 | + REVISION=$(git describe --tags --long | awk -F- '{print $2}') |
| 45 | + export PR_NUMBER REVISION |
| 46 | +
|
| 47 | + # This will display a full log of what would happen if we were to bump the version. |
| 48 | + bump-my-version bump --dry-run --verbose "$RELEASE_KIND" |
| 49 | +
|
| 50 | + # This retrieves the current and new version numbers as a JSON-formatted string. |
| 51 | + VERSION_INFO=$(bump-my-version show --format json --increment "$RELEASE_KIND" current_version new_version) |
| 52 | + echo "CURRENT_VERSION=$(echo $VERSION_INFO | jq -r .current_version)" >> $GITHUB_ENV |
| 53 | + echo "NEW_VERSION=$(echo $VERSION_INFO | jq -r .new_version)" >> $GITHUB_ENV |
| 54 | +
|
| 55 | + - name: Display the version hint |
| 56 | + uses: s-gehring/singleton-comment@v1 |
| 57 | + with: |
| 58 | + comment-body: | |
| 59 | + **Version hint:** ${{ env.RELEASE_KIND }} |
| 60 | + **Current version:** ${{ env.CURRENT_VERSION }} |
| 61 | + **New version (when merged):** ${{ env.NEW_VERSION }} |
0 commit comments