chore: Release version v0.12.0 #152
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: Semver checks | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| RUSTFLAGS: "-D warnings" | |
| RUSTDOCFLAGS: '--deny warnings' | |
| MINIMUM_SUPPORTED_RUST_VERSION: 1.85.0 | |
| RUST_CHANNEL: stable | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize, ready_for_review] | |
| branches: | |
| - main | |
| paths-ignore: | |
| - CHANGELOG.md | |
| workflow_dispatch: | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-branches: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: you can't run this action on 'main' branch | |
| run: | | |
| if [[ "$GITHUB_REF_NAME" = "main" ]]; then | |
| exit 1 | |
| fi | |
| env: | |
| GITHUB_REF_NAME: ${{ github.ref_name }} | |
| setup: | |
| needs: check-branches | |
| outputs: | |
| currentVersion: ${{ steps.current.outputs.version }} | |
| nextVersion: ${{ steps.next.outputs.version }} | |
| nextStep: ${{ steps.nextStep.outputs.nextStep }} | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Delete old cargo-semver-checks comments | |
| continue-on-error: true | |
| run: | | |
| gh pr view "${{ github.event.number }}" --json comments --jq '.comments[] | select(.author.login == "github-actions") | .url' | grep -oE 'issuecomment-(.+)' | cut -d '-' -f2 > comments.txt | |
| xargs -I % gh api -X DELETE "/repos/${GH_REPOSITORY}/issues/comments/%" < comments.txt | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPOSITORY: ${{ github.repository }} | |
| - name: Install Rust | |
| run: | | |
| rustup update --no-self-update ${RUST_CHANNEL} | |
| rustup component add --toolchain ${RUST_CHANNEL} cargo | |
| rustup default ${RUST_CHANNEL} | |
| env: | |
| RUST_CHANNEL: ${{ env.RUST_CHANNEL }} | |
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # ratchet:Swatinem/rust-cache@v2 | |
| - name: List the releases on GitHub | |
| id: current | |
| run: echo "version=$(git tag --sort=-creatordate | head -n 1)" >> "$GITHUB_OUTPUT" | |
| - name: Get next version | |
| id: next | |
| run: echo "version=v$(cargo pkgid | cut -d '#' -f2)" >> "$GITHUB_OUTPUT" | |
| - name: Compute next step | |
| id: nextStep | |
| if: ${{ steps.current.outputs.version == steps.next.outputs.version }} | |
| run: | | |
| if [[ "${VERSION}" == "${NEXT_VERSION}" ]]; then | |
| echo "nextStep=compute" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "nextStep=nope" >> "$GITHUB_OUTPUT" | |
| fi | |
| env: | |
| VERSION: ${{ steps.current.outputs.version }} | |
| NEXT_VERSION: ${{ steps.next.outputs.version }} | |
| cargo-semver-checks: | |
| needs: setup | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| runs-on: ubuntu-latest | |
| if: ${{ needs.setup.outputs.nextStep != 'compute' }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| fetch-tags: true | |
| - name: Install Rust | |
| run: | | |
| rustup update --no-self-update ${RUST_CHANNEL} | |
| rustup component add --toolchain ${RUST_CHANNEL} cargo | |
| rustup default ${RUST_CHANNEL} | |
| env: | |
| RUST_CHANNEL: ${{ env.RUST_CHANNEL }} | |
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # ratchet:Swatinem/rust-cache@v2 | |
| - uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae | |
| - name: Show release type | |
| id: semver | |
| run: | | |
| echo "release=$(bash ./.github/workflows/semver.sh diff ${VERSION} ${NEXT_VERSION})" >> "$GITHUB_OUTPUT" | |
| env: | |
| VERSION: ${{ needs.setup.outputs.currentVersion }} | |
| NEXT_VERSION: ${{ needs.setup.outputs.nextVersion }} | |
| - name: Prepare report.md | |
| run: | | |
| { | |
| printf "> [!WARNING]" | |
| printf "> According to \`cargo-semver-checks\`, the next release version doesn\'t respect semantic versioning." | |
| printf '```bash' | |
| } > ./report.md | |
| - name: Run cargo semver-checks | |
| id: check | |
| run: | | |
| printf "\`cargo-semver-checks\` has detected some issues: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n" > report.md | |
| printf '```bash' >> report.md | |
| cargo semver-checks --color never --baseline-rev "$VERSION" --release-type "$RELEASE_TYPE" 2>&1 | tee -a report.md | |
| if [[ "${PIPESTATUS[0]}" != "0" ]]; then | |
| printf '```' >> report.md | |
| exit 1 | |
| fi | |
| continue-on-error: true | |
| env: | |
| VERSION: ${{ needs.setup.outputs.currentVersion }} | |
| RELEASE_TYPE: ${{ steps.semver.outputs.release }} | |
| - name: Publish semver-checks report | |
| if: ${{ steps.check.outcome != 'success' }} | |
| run: | | |
| gh pr comment ${{ github.event.number }} --body-file ./report.md | |
| exit 1 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish semver-checks report | |
| if: ${{ steps.check.outcome != 'success' }} | |
| run: | | |
| gh pr comment ${{ github.event.number }} --body-file ./report.md | |
| exit 1 | |
| compute-next-version: | |
| needs: setup | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| if: ${{ needs.setup.outputs.nextStep == 'compute' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Install Rust | |
| run: | | |
| rustup update --no-self-update ${RUST_CHANNEL} | |
| rustup component add --toolchain ${RUST_CHANNEL} cargo | |
| rustup default ${RUST_CHANNEL} | |
| env: | |
| RUST_CHANNEL: ${{ env.RUST_CHANNEL }} | |
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # ratchet:Swatinem/rust-cache@v2 | |
| - name: Install cargo-semver-checks | |
| run: cargo install cargo-semver-checks | |
| - name: Determine the next version | |
| id: bump | |
| continue-on-error: true | |
| run: | | |
| b="major" | |
| for t in patch minor; do | |
| echo "Checking whether the next version is $t" | |
| if cargo semver-checks --color never --baseline-rev "${CURRENT_VERSION}" --release-type "$t"; then | |
| b="$t" | |
| break | |
| fi | |
| done | |
| echo $b | |
| echo "bump=$b" >> "$GITHUB_OUTPUT" | |
| env: | |
| CURRENT_VERSION: ${{ needs.setup.outputs.currentVersion }} | |
| - name: Comment the pull request | |
| run: | | |
| echo "::info title=Next version:: Last public version is '${VERSION}' but version of this branch is '${NEXT_VERSION}'." | |
| { | |
| printf "This pull request is not ready because version \`%s\` is already published." "${VERSION}" | |
| printf "\nAccording to \`cargo-semver-checks\`, the next version should be \`v%s\`:" "$(bash .github/workflows/semver.sh bump $BUMP ${VERSION} | tr -d "\n")" | |
| printf "\n" | |
| echo '```shell' | |
| printf "git checkout %s\n" "$branch" | |
| echo "cargo release $BUMP --no-push --no-tag --no-publish --no-confirm --execute" | |
| echo "git push" | |
| echo '```' | |
| } >> report.md | |
| gh pr comment ${{ github.event.number }} --body-file ./report.md | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| VERSION: ${{ needs.setup.outputs.currentVersion }} | |
| NEXT_VERSION: ${{ needs.setup.outputs.nextVersion }} | |
| branch: '${{ toJSON(github.head_ref) }}' | |
| BUMP: ${{ steps.bump.outputs.bump }} | |