mirror of https://github.com/fafhrd91/actix-web
87 lines
2.6 KiB
YAML
87 lines
2.6 KiB
YAML
name: Semver Checks
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
jobs:
|
|
semver-checks:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install cargo-semver-checks
|
|
uses: taiki-e/install-action@cf525cb33f51aca27cd6fa02034117ab963ff9f1 # v2.75.22
|
|
with:
|
|
tool: cargo-semver-checks
|
|
|
|
- name: Run cargo semver-checks
|
|
id: semver
|
|
shell: bash
|
|
run: |
|
|
set -o pipefail
|
|
|
|
output_file="$(mktemp)"
|
|
|
|
cargo semver-checks \
|
|
--workspace \
|
|
--release-type=patch \
|
|
--baseline-rev "${{ github.event.pull_request.base.sha }}" \
|
|
2>&1 | tee "$output_file"
|
|
status=$?
|
|
|
|
semver_type=patch
|
|
if grep -q "semver requires new major version" "$output_file"; then
|
|
semver_type=major
|
|
elif grep -q "semver requires new minor version" "$output_file"; then
|
|
semver_type=minor
|
|
elif grep -q "semver requires new patch version" "$output_file"; then
|
|
semver_type=patch
|
|
fi
|
|
|
|
{
|
|
echo "exit_code=$status"
|
|
echo "output_file=$output_file"
|
|
echo "semver_type=$semver_type"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
exit 0
|
|
|
|
- name: Summarize cargo semver-checks output
|
|
if: always() && steps.semver.outcome != 'skipped'
|
|
shell: bash
|
|
run: |
|
|
summary_file="${{ steps.semver.outputs.output_file }}"
|
|
status="${{ steps.semver.outputs.exit_code }}"
|
|
|
|
{
|
|
echo "## cargo semver-checks"
|
|
echo
|
|
echo "- Base SHA: \`${{ github.event.pull_request.base.sha }}\`"
|
|
echo "- Head SHA: \`${{ github.event.pull_request.head.sha }}\`"
|
|
echo "- Required release: \`${{ steps.semver.outputs.semver_type }}\`"
|
|
echo "- cargo semver-checks exit code: \`$status\`"
|
|
|
|
echo
|
|
echo "<details><summary>Command output</summary>"
|
|
echo
|
|
echo '```text'
|
|
sed -n '1,200p' "$summary_file"
|
|
total_lines="$(wc -l < "$summary_file")"
|
|
if [ "$total_lines" -gt 200 ]; then
|
|
echo
|
|
echo "[truncated; showing first 200 of ${total_lines} lines]"
|
|
fi
|
|
echo '```'
|
|
echo "</details>"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|