Skip to content

Commit 9bdcd8c

Browse files
committed
Refactor GitHub workflows for improved clarity
Move repeated values into environment variables and update git configuration. Add explicit permissions and simplify conditional logic in CI workflows.
1 parent a5184c6 commit 9bdcd8c

3 files changed

Lines changed: 35 additions & 15 deletions

File tree

.github/workflows/bump-and-release.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,26 @@ jobs:
4646

4747
- name: Configure git
4848
run: |
49-
git config user.name "github-actions[bot]"
50-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
49+
git config user.name "nerjs"
50+
git config user.email "nerjs.stap@gmail.com"
5151
5252
- name: Compute next version
5353
id: ver
54+
env:
55+
BUMP_LEVEL: ${{ inputs.version }}
56+
IS_BETA: ${{ inputs.beta }}
5457
run: |
5558
set -euo pipefail
5659
CURRENT=$(cargo read-manifest | jq -r .version)
5760
BASE_CURRENT=${CURRENT%%-*}
5861
IFS=. read MAJ MIN PAT <<< "$BASE_CURRENT"
59-
case "${{ inputs.version }}" in
62+
case "$BUMP_LEVEL" in
6063
patch) NEXT_BASE="$MAJ.$MIN.$((PAT+1))" ;;
6164
minor) NEXT_BASE="$MAJ.$((MIN+1)).0" ;;
6265
major) NEXT_BASE="$((MAJ+1)).0.0" ;;
6366
esac
6467
git fetch --tags
65-
if [ "${{ inputs.beta }}" = "true" ]; then
68+
if [ "$IS_BETA" = "true" ]; then
6669
N=$(git tag --list "v${NEXT_BASE}-beta.*" | sed "s/.*-beta\.//" | sort -n | tail -n1)
6770
N=$((${N:-0}+1))
6871
NEXT="${NEXT_BASE}-beta.${N}"
@@ -73,22 +76,28 @@ jobs:
7376
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
7477
7578
- name: Commit
79+
env:
80+
NEXT_VERSION: ${{ steps.ver.outputs.next }}
81+
COMMIT_NOTE: ${{ inputs.commit_note }}
7682
run: |
77-
VERSION="${{ steps.ver.outputs.next }}"
78-
MSG="Bump version to v${VERSION}"
79-
NOTE="${{ inputs.commit_note }}"
80-
if [ -n "$NOTE" ]; then
81-
MSG="${MSG}"$'\n\n'"${NOTE}"
83+
set -euo pipefail
84+
MSG="Bump version to v${NEXT_VERSION}"
85+
if [ -n "$COMMIT_NOTE" ]; then
86+
MSG="${MSG}"$'\n\n'"${COMMIT_NOTE}"
8287
fi
8388
git add Cargo.toml Cargo.lock
8489
git commit -m "$MSG"
8590
8691
- name: Tag and push
8792
id: tag
93+
env:
94+
NEXT_VERSION: ${{ steps.ver.outputs.next }}
95+
BRANCH: ${{ github.ref_name }}
8896
run: |
89-
TAG="v${{ steps.ver.outputs.next }}"
97+
set -euo pipefail
98+
TAG="v${NEXT_VERSION}"
9099
git tag -a "$TAG" -m "$TAG"
91-
git push origin "${{ github.ref_name }}" --follow-tags
100+
git push origin "$BRANCH" --follow-tags
92101
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
93102
94103
release:
@@ -103,9 +112,12 @@ jobs:
103112
- name: Create GitHub Release
104113
env:
105114
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
115+
TAG: ${{ needs.bump.outputs.tag }}
116+
IS_BETA: ${{ inputs.beta }}
106117
run: |
118+
set -euo pipefail
107119
FLAGS="--generate-notes"
108-
if [ "${{ inputs.beta }}" = "true" ]; then
120+
if [ "$IS_BETA" = "true" ]; then
109121
FLAGS="$FLAGS --prerelease"
110122
fi
111-
gh release create "${{ needs.bump.outputs.tag }}" $FLAGS
123+
gh release create "$TAG" $FLAGS

.github/workflows/ci-deps.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ on:
99
pull_request:
1010
branches: [dependencies]
1111

12+
permissions:
13+
contents: read
14+
1215
concurrency:
1316
group: ${{ github.workflow }}-${{ github.ref }}
1417
cancel-in-progress: true
1518

1619
jobs:
1720
check-test:
18-
if: ${{ !contains(github.event.head_commit.message || github.event.pull_request.title || '', '[skip-CI]') }}
21+
if: ${{ !contains(github.event.head_commit.message || '', '[skip-CI]') }}
1922
runs-on: ubuntu-latest
2023
steps:
2124
- uses: actions/checkout@v6

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ on:
77
pull_request:
88
branches: [master]
99

10+
permissions:
11+
contents: read
12+
1013
concurrency:
1114
group: ${{ github.workflow }}-${{ github.ref }}
1215
cancel-in-progress: true
1316

1417
jobs:
1518
fmt:
16-
if: ${{ !contains(github.event.head_commit.message || github.event.pull_request.title || '', '[skip-CI]') }}
19+
if: ${{ !contains(github.event.head_commit.message || '', '[skip-CI]') }}
1720
runs-on: ubuntu-latest
1821
steps:
1922
- uses: actions/checkout@v6
@@ -51,6 +54,8 @@ jobs:
5154
name: test (${{ matrix.env.name }} / ${{ matrix.rust }})
5255
runs-on: ubuntu-latest
5356
container: ${{ matrix.env.container }}
57+
env:
58+
RUSTUP_TOOLCHAIN: ${{ matrix.rust }}
5459
steps:
5560
- name: Prep (debian)
5661
if: matrix.env.name == 'debian'

0 commit comments

Comments
 (0)