Skip to content

Commit 07b2633

Browse files
authored
move semver to its own workflow
It only makes sense during PRs, since its function is to make sure that the PR contains the `breaking change` label if there's a breaking change. Previously, it would run (and fail) on main. Not good!
1 parent 61a61bc commit 07b2633

File tree

2 files changed

+42
-37
lines changed

2 files changed

+42
-37
lines changed

.github/workflows/rust.yml

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -83,40 +83,3 @@ jobs:
8383
- uses: actions/checkout@v4
8484
- name: cargo fmt
8585
run: cargo fmt --check
86-
87-
88-
semver:
89-
permissions:
90-
contents: read
91-
runs-on: ubuntu-latest
92-
steps:
93-
94-
- name: Check out repo
95-
uses: actions/checkout@v4
96-
97-
- name: Also fetch target branch
98-
run: git fetch origin "$GITHUB_BASE_REF"
99-
100-
- name: Install semver-checks
101-
run: |
102-
set -euo pipefail
103-
cd "$RUNNER_TEMP"
104-
gh release -R obi1kenobi/cargo-semver-checks download -p cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz -O - | tar xz
105-
working-directory: ${{ env.RUNNER_TEMP }}
106-
env:
107-
GH_TOKEN: ${{ github.token }}
108-
109-
- name: Run semver-checks
110-
run: |
111-
if ! "$RUNNER_TEMP/cargo-semver-checks" semver-checks --baseline-rev "origin/$GITHUB_BASE_REF" ; then
112-
# There were breaking changes. Make sure we have the appropriate label!
113-
breaking_change_label_count="$(gh pr view ${{ github.event.number }} --json labels | jq '.labels | map(select(.name == "breaking change")) | length')"
114-
if [[ "$breaking_change_label_count" != 1 ]]; then
115-
echo "::error title=semver-checks::semver-checks found breaking changes, but the 'breaking change' label isn't applied. Please add that label."
116-
exit 1
117-
else
118-
echo "::warning title=semver-checks::semver-checks found breaking changes. The 'breaking change' label is applied, so no action needed if this is an acceptable change."
119-
fi
120-
fi
121-
env:
122-
GH_TOKEN: ${{ github.token }}

.github/workflows/semver.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Semver
2+
3+
on:
4+
pull_request:
5+
branches: [ "main", "feature/*" ]
6+
7+
jobs:
8+
check:
9+
permissions:
10+
contents: read
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Check out repo
15+
uses: actions/checkout@v4
16+
17+
- name: Also fetch target branch
18+
run: git fetch origin "$GITHUB_BASE_REF"
19+
20+
- name: Install semver-checks
21+
run: |
22+
set -euo pipefail
23+
cd "$RUNNER_TEMP"
24+
gh release -R obi1kenobi/cargo-semver-checks download -p cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz -O - | tar xz
25+
working-directory: ${{ env.RUNNER_TEMP }}
26+
env:
27+
GH_TOKEN: ${{ github.token }}
28+
29+
- name: Run semver-checks
30+
run: |
31+
if ! "$RUNNER_TEMP/cargo-semver-checks" semver-checks --baseline-rev "origin/$GITHUB_BASE_REF" ; then
32+
# There were breaking changes. Make sure we have the appropriate label!
33+
breaking_change_label_count="$(gh pr view ${{ github.event.number }} --json labels | jq '.labels | map(select(.name == "breaking change")) | length')"
34+
if [[ "$breaking_change_label_count" != 1 ]]; then
35+
echo "::error title=semver-checks::semver-checks found breaking changes, but the 'breaking change' label isn't applied. Please add that label."
36+
exit 1
37+
else
38+
echo "::warning title=semver-checks::semver-checks found breaking changes. The 'breaking change' label is applied, so no action needed if this is an acceptable change."
39+
fi
40+
fi
41+
env:
42+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)