ci: improve workflows with stricter checks, caching, and idempotency

CI improvements:
- Add concurrency group to cancel redundant runs on same branch
- Add cargo cache to fmt job (was missing entirely)
- Add timeout-minutes: 5 to fast jobs (fmt, clippy, test) for fail-fast
- Change RUST_BACKTRACE from 'short' to '1' for better CI debuggability
- Pin push trigger to branches: [main] to avoid double-firing on PR merges
- Test minimum supported Neovim (0.11.0) instead of latest patch (0.11.3)

Release improvements:
- Enforce RUSTFLAGS: -D warnings at env level and in matrix rustflags
- Remove redundant checkout in release job (only needs env vars)
- Add release notes generation from git log since previous tag
- Make release creation idempotent (check if release exists before creating)
- Fix release_id not being set when release already exists
This commit is contained in:
2026-06-03 20:11:03 -03:00
parent a2ca49a64c
commit b33ed90810
2 changed files with 81 additions and 33 deletions
+52 -21
View File
@@ -11,6 +11,7 @@ permissions:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: short
RUSTFLAGS: -D warnings
jobs:
build:
@@ -22,19 +23,19 @@ jobs:
include:
- target: x86_64-unknown-linux-gnu
apt: ""
rustflags: ""
rustflags: "-D warnings"
- target: aarch64-unknown-linux-gnu
# gcc-aarch64-linux-gnu ships the cross compiler/binutils
# but no target libc; libc6-dev-arm64-cross adds Scrt1.o,
# crti.o, and friends needed at link time.
apt: "gcc-aarch64-linux-gnu libc6-dev-arm64-cross"
rustflags: ""
rustflags: "-D warnings"
- target: x86_64-unknown-linux-musl
apt: "musl-tools"
rustflags: ""
rustflags: "-D warnings"
- target: aarch64-unknown-linux-musl
apt: ""
rustflags: "-C linker=rust-lld -C link-self-contained=yes"
rustflags: "-D warnings -C linker=rust-lld -C link-self-contained=yes"
steps:
- uses: actions/checkout@v4
@@ -56,8 +57,8 @@ jobs:
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-release-${{ matrix.target }}-
restore-keys:
- ${{ runner.os }}-cargo-release-${{ matrix.target }}-
- name: Build nuwiki-ls
env:
@@ -93,8 +94,6 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all build artifacts
# Paired with upload-artifact@v3 above. v3 has no merge-multiple
# option and nests each artifact under its own subdirectory.
@@ -111,6 +110,26 @@ jobs:
apt-get update && apt-get install -y --no-install-recommends curl
fi
- name: Generate release notes
id: notes
run: |
set -euo pipefail
# Get commits since the previous tag (or the first commit if this is the first release).
prev_tag=$(git tag --sort=-version:refname | awk "NR==2" || echo "")
if [ -n "$prev_tag" ]; then
log=$(git log --oneline "$prev_tag"..HEAD)
else
log=$(git log --oneline --max-parents=0..HEAD)
fi
# Write notes to a file for later use.
cat > release-notes.txt <<EOF
**Full Changelog**: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/compare/${prev_tag:-$(git rev-list --max-parents=0 HEAD)}...${GITHUB_REF_NAME}
**Changes**:
$log
EOF
echo "Generated release notes"
- name: Create Gitea release + upload assets
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
@@ -125,21 +144,33 @@ jobs:
fi
echo "Releasing $TAG to $GITEA_SERVER/$REPO"
payload=$(jq -n --arg tag "$TAG" --arg name "$TAG" \
'{tag_name: $tag, name: $name, draft: false, prerelease: false}')
release_id=$(curl --fail --silent --show-error \
# Check if a release for this tag already exists (idempotency).
release_id=""
existing=$(curl --fail --silent --show-error -o /dev/null -w "%{http_code}" \
-H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/json" \
-d "$payload" \
"$GITEA_SERVER/api/v1/repos/$REPO/releases" \
| jq -r '.id')
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
echo "::error::failed to create release"
exit 1
"$GITEA_SERVER/api/v1/repos/$REPO/releases/tags/$TAG" \
|| true)
if [ "$existing" = "200" ]; then
echo "Release for $TAG already exists — fetching existing id"
release_id=$(curl --fail --silent --show-error \
-H "Authorization: token $RELEASE_TOKEN" \
"$GITEA_SERVER/api/v1/repos/$REPO/releases/tags/$TAG" \
| jq -r '.id')
else
payload=$(jq -n --arg tag "$TAG" --arg name "$TAG" \
'{tag_name: $tag, name: $name, draft: false, prerelease: false}')
release_id=$(curl --fail --silent --show-error \
-H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/json" \
-d "$payload" \
"$GITEA_SERVER/api/v1/repos/$REPO/releases" \
| jq -r '.id')
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
echo "::error::failed to create release"
exit 1
fi
echo "Created release id=$release_id"
fi
echo "Created release id=$release_id"
# download-artifact@v3 nests each artifact under its own dir
# (artifacts/<artifact-name>/<file>), so recurse.