mirror of https://github.com/fafhrd91/actix-web
94 lines
2.9 KiB
YAML
94 lines
2.9 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
|
|
persist-credentials: false
|
|
|
|
- name: Install Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install cargo-semver-checks
|
|
uses: taiki-e/install-action@d9be7d8cda89035c9c843f78bd44d4f72d8403d4 # v2.79.7
|
|
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
|
|
env:
|
|
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
SEMVER_TYPE: ${{ steps.semver.outputs.semver_type }}
|
|
STATUS: ${{ steps.semver.outputs.exit_code }}
|
|
SUMMARY_FILE: ${{ steps.semver.outputs.output_file }}
|
|
run: |
|
|
summary_file="$SUMMARY_FILE"
|
|
status="$STATUS"
|
|
|
|
{
|
|
echo "## cargo semver-checks"
|
|
echo
|
|
echo "- Base SHA: \`${BASE_SHA}\`"
|
|
echo "- Head SHA: \`${HEAD_SHA}\`"
|
|
echo "- Required release: \`${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"
|