Develop #66
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: Semver checks | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: "-D warnings" | |
RUSTDOCFLAGS: '--deny warnings' | |
MINIMUM_SUPPORTED_RUST_VERSION: 1.80.1 | |
permissions: | |
packages: write | |
contents: write | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
branches: | |
- main | |
paths-ignore: | |
- CHANGELOG.md | |
workflow_dispatch: | |
workflow_run: | |
workflows: ['Prepare a release'] | |
types: | |
- completed | |
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 | |
cargo-semver-checks: | |
needs: check-branches | |
permissions: | |
pull-requests: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- 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 -E 'issuecomment-(.+)' | cut -d '-' -f2 > comments.txt | |
xargs -I {} gh api -X DELETE "/repos/MAIF/yozefu/issues/comments/{}" < comments.txt | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Install cargo-semver-checks | |
run: cargo install cargo-semver-checks | |
- 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 --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT" | |
- name: Make sure version is updated | |
if: ${{ steps.current.outputs.version == steps.next.outputs.version }} | |
run: | | |
echo "::warning title=Next version:: Last public version is '${{ steps.current.outputs.version }}' but version of this branch is '${{ steps.next.outputs.version }}'. Did you forget to update the version? More details at https://github.com/MAIF/yozefu/blob/main/docs/release/README.md" | |
printf 'This pull request is not ready because the crate version is equals to the latest git tag version `' > report.md | |
printf "${{ steps.next.outputs.version }}" >> report.md | |
printf '`. I think you forgot to bump the version. More details at https://github.com/MAIF/yozefu/blob/main/docs/release/README.md' >> report.md | |
gh pr comment ${{ github.event.number }} --body-file ./report.md | |
exit 1 | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Show release type | |
id: semver | |
run: | | |
chmod u+x ./.github/workflows/semver.sh | |
echo "release=$(./.github/workflows/semver.sh diff ${{ steps.current.outputs.version }} ${{ steps.next.outputs.version }})" >> "$GITHUB_OUTPUT" | |
- name: Prepare report.md | |
if: ${{ steps.next.outputs.version == '' }} | |
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 | |
if: ${{ steps.next.outputs.version != '' && steps.semver.outputs.release != '' }} | |
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 --package yozefu-lib --package yozefu-app --package yozefu-wasm-types --package yozefu-command --baseline-rev "${{ steps.current.outputs.version }}" --release-type "${{ steps.semver.outputs.release }}" 2>&1 | tee -a report.md | |
if [[ "${PIPESTATUS[0]}" != "0" ]]; then | |
printf '```' >> report.md | |
exit 1 | |
fi | |
continue-on-error: true | |
- 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 }} |