Skip to content

Semver checks

Semver checks #18

Workflow file for this run

# This workflow tests smver compatibilty.
# For PRs it checks if PR makes any API breaking changes, and assings appropriate label if so.
name: Semver checks
on:
pull_request:
branches:
- main
- 'branch-*'
push:
tags:
- v*.*.*
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_ID: ${{ github.event.number }}
jobs:
semver-pull-request:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
pull-requests: write
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
# I don't know any way to do this using checkout action
- name: Fetch PR base
run: git fetch origin "$PR_BASE"
- name: Install semver-checks
# Official action uses binary releases fetched from GitHub
# If this pipeline becomes too slow, we should do this too
run: cargo install cargo-semver-checks --no-default-features
- name: Verify the API compatibilty with PR base
id: semver-pr-check
run: make semver-rev rev="$PR_BASE"
continue-on-error: true
- name: Remove breaking label on success
run: gh pr edit "$PR_ID" --remove-label semver-checks-breaking
if: steps.semver-pr-check.outcome == 'success'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
- name: Add breaking label on failure
run: gh pr edit "$PR_ID" --add-label semver-checks-breaking
if: steps.semver-pr-check.outcome != 'success'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
semver-push-tag:
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
pull-requests: write
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Install semver-checks
run: cargo install cargo-semver-checks --no-default-features
- name: Verify that's it's safe to publish the version.
run: make semver-version