2020 type : string
2121 default : " "
2222
23- permissions :
24- contents : write
25-
2623jobs :
2724 checks :
2825 uses : ./.github/workflows/checks.yml
@@ -36,116 +33,14 @@ jobs:
3633 - run : cargo test --all-features
3734
3835 bump :
39- needs :
36+ needs :
4037 - checks
4138 - test
4239 runs-on : ubuntu-latest
43- outputs :
44- tag : ${{ steps.tag.outputs.tag }}
4540 steps :
46- - uses : actions/checkout@v7
41+ - uses : nerjs/bump-release-action@v1
4742 with :
48- # PAT so the bump commit can be pushed to protected master.
49- # GITHUB_TOKEN (github-actions[bot]) cannot bypass branch rules.
43+ # PAT: GITHUB_TOKEN cannot push the bump commit to protected master.
5044 token : ${{ secrets.RELEASE_TOKEN }}
51- # Keep the PAT out of .git/config for later steps; the push step
52- # passes it explicitly. fetch-depth 0 already brings every tag.
53- persist-credentials : false
54- fetch-depth : 0
55-
56- - uses : Swatinem/rust-cache@v2
57- - uses : taiki-e/install-action@v2
58- with :
59- tool : cargo-edit
60-
61- - name : Configure git
62- run : |
63- git config user.name "nerjs"
64- git config user.email "nerjs.stap@gmail.com"
65-
66- - name : Compute next version
67- id : ver
68- env :
69- ACTION : ${{ inputs.version }}
70- run : |
71- set -euo pipefail
72- ver() { cargo read-manifest | jq -r .version; }
73- PREV=$(ver)
74- # Version math is delegated to cargo set-version; bash only routes the action.
75- # `beta` covers both starting a patch pre-release and incrementing an existing
76- # one - set-version picks by current state, and updates Cargo.lock as it goes.
77- # --workspace also covers a lone package (a one-member workspace).
78- case "$ACTION" in
79- patch|minor|major) cargo set-version --workspace --bump "$ACTION" ;;
80- beta) cargo set-version --workspace --bump beta ;;
81- beta-minor|beta-major)
82- # `--bump beta` always patches the base, so it cannot start a minor/major
83- # pre-release. set-version also refuses downgrades (0.2.0 -> 0.2.0-beta.1),
84- # ruling out "bump then suffix". Bump the target base ourselves and set the
85- # pre-release in one shot - always an upgrade from the current version.
86- base=${PREV%%-*}; IFS=. read -r maj min _ <<< "$base"
87- case "$ACTION" in
88- beta-minor) target="$maj.$((min+1)).0" ;;
89- beta-major) target="$((maj+1)).0.0" ;;
90- esac
91- cargo set-version --workspace "$target-beta.1" ;;
92- finalize) cargo set-version --workspace --bump release ;;
93- *) echo "::error::unknown action: $ACTION"; exit 1 ;;
94- esac
95- NEXT=$(ver)
96- # `finalize` with no active pre-release is a no-op; an unchanged version would
97- # produce an empty commit below. Fail loud instead of releasing nothing.
98- if [ "$NEXT" = "$PREV" ]; then
99- echo "::error::version unchanged ($PREV): '$ACTION' is a no-op here"
100- exit 1
101- fi
102- echo "next=$NEXT" >> "$GITHUB_OUTPUT"
103-
104- - name : Commit
105- env :
106- NEXT_VERSION : ${{ steps.ver.outputs.next }}
107- COMMIT_NOTE : ${{ inputs.commit_note }}
108- run : |
109- set -euo pipefail
110- MSG="Bump version to v${NEXT_VERSION}"
111- if [ -n "$COMMIT_NOTE" ]; then
112- MSG="${MSG}"$'\n\n'"${COMMIT_NOTE}"
113- fi
114- # Stage every manifest the bump touched - root plus all workspace
115- # members - and Cargo.lock. -u is limited to tracked files, so the
116- # clean CI checkout never stages build artifacts.
117- git add -u
118- git commit -m "$MSG"
119-
120- - name : Tag and push
121- id : tag
122- env :
123- NEXT_VERSION : ${{ steps.ver.outputs.next }}
124- BRANCH : ${{ github.ref_name }}
125- REPO : ${{ github.repository }}
126- RELEASE_TOKEN : ${{ secrets.RELEASE_TOKEN }}
127- run : |
128- set -euo pipefail
129- TAG="v${NEXT_VERSION}"
130- git tag -a "$TAG" -m "$TAG"
131- git push "https://x-access-token:${RELEASE_TOKEN}@github.com/${REPO}.git" "$BRANCH" --follow-tags
132- echo "tag=$TAG" >> "$GITHUB_OUTPUT"
133-
134- release :
135- needs : bump
136- runs-on : ubuntu-latest
137- steps :
138- - uses : actions/checkout@v7
139- with :
140- ref : ${{ needs.bump.outputs.tag }}
141-
142- - name : Create GitHub Release
143- env :
144- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
145- TAG : ${{ needs.bump.outputs.tag }}
146- run : |
147- set -euo pipefail
148- FLAGS="--generate-notes"
149- # A pre-release tag carries a `-beta.N` suffix; mark the Release accordingly.
150- case "$TAG" in *-*) FLAGS="$FLAGS --prerelease" ;; esac
151- gh release create "$TAG" $FLAGS
45+ version : ${{ inputs.version }}
46+ commit_note : ${{ inputs.commit_note }}
0 commit comments