Private
Public Access
1
0

refactor: update CI for native per-OS runners
Some checks failed
CI/CD Pipeline / Code Format (push) Failing after 6s
CI/CD Pipeline / Clippy Lints (push) Failing after 11s
CI/CD Pipeline / Unit Tests (push) Failing after 1s
CI/CD Pipeline / Build Debian Package (push) Has been skipped
CI/CD Pipeline / Build RPM Package (push) Has been skipped
CI/CD Pipeline / Build Alpine Package (push) Has been skipped
CI/CD Pipeline / Build Arch Package (push) Has been skipped
CI/CD Pipeline / Security Audit (push) Failing after 1s

- Replace generic "linux" runner label with dedicated per-OS labels
  (ubuntu-24.04, fedora, alpine, arch)
- Remove all container declarations (native runner execution)
- Add build gate dependencies: build jobs need fmt+clippy+test
- Extract release upload logic into reusable scripts/upload-release.sh
- Fix build-alpine.sh: remove hardcoded container paths, add
  SKIP_CARGO_BUILD support
- Fix build-arch.sh: remove hardcoded container paths, add
  SKIP_CARGO_BUILD support
- Fix build-rpm.sh: remove sudo, native runner compatible
- Remove Dockerfile.rpm and Dockerfile.arch (no longer needed)
- Add sudo to Ubuntu/Fedora/Arch package installs for safety
- Add nodejs to Alpine deps for Gitea Actions compatibility
- Make upload-release.sh POSIX sh compatible (Alpine)
- Fix curl -sf to curl -s in upload-release.sh (404 on new releases)
This commit is contained in:
2026-04-26 19:21:09 +00:00
parent 44c182764e
commit a4026a471a
7 changed files with 161 additions and 158 deletions

View File

@ -14,8 +14,7 @@ env:
jobs:
fmt:
name: Code Format
runs-on: linux
container: node:18
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
@ -28,16 +27,15 @@ jobs:
clippy:
name: Clippy Lints
runs-on: linux
container: node:18
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
run: |
apt-get update
apt-get install -y libsystemd-dev pkg-config
sudo apt-get update
sudo apt-get install -y libsystemd-dev pkg-config
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
@ -48,16 +46,15 @@ jobs:
test:
name: Unit Tests
runs-on: linux
container: node:18
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
run: |
apt-get update
apt-get install -y libsystemd-dev pkg-config
sudo apt-get update
sudo apt-get install -y libsystemd-dev pkg-config
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
@ -66,17 +63,18 @@ jobs:
audit:
name: Security Audit
runs-on: linux
container: node:18
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
run: |
apt-get update
apt-get install -y libsystemd-dev pkg-config
sudo apt-get update
sudo apt-get install -y libsystemd-dev pkg-config
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run cargo-audit
run: |
cargo install cargo-audit
@ -84,140 +82,114 @@ jobs:
build-deb:
name: Build Debian Package
runs-on: linux
container: node:18-bookworm
needs: [fmt, clippy, test]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install build dependencies
run: |
apt-get update
apt-get install -y build-essential debhelper cargo rustc libsystemd-dev pkg-config
sudo apt-get update
sudo apt-get install -y build-essential debhelper pkg-config libsystemd-dev
- name: Build Debian package
run: dpkg-buildpackage -us -uc -b
run: sudo dpkg-buildpackage -us -uc -b
- name: Upload to Gitea Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITEA_TOKEN: ${{ secrets.giteatoken }}
GITEA_API: https://gitea.moon-dragon.us/api/v1
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
FILE=$(ls ../linux-patch-api_*.deb 2>/dev/null | head -1)
[ -z "$FILE" ] && echo "No .deb found" && exit 0
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_API/repos/echo/linux_patch_api/releases/tags/$TAG_NAME" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -z "$RELEASE_ID" ]; then
RESPONSE=$(curl -s -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" "$GITEA_API/repos/echo/linux_patch_api/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
fi
UPLOAD_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST -H "Authorization: token $GITEA_TOKEN" -F "attachment=@$FILE" "$GITEA_API/repos/echo/linux_patch_api/releases/$RELEASE_ID/assets?name=$(basename $FILE)")
HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2)
if [ "$HTTP_CODE" != "201" ] && [ "$HTTP_CODE" != "200" ]; then echo "Upload failed $HTTP_CODE" && exit 1; fi
echo "Successfully uploaded $FILE"
chmod +x scripts/upload-release.sh
./scripts/upload-release.sh "$TAG_NAME" "$FILE"
build-rpm:
name: Build RPM Package
runs-on: linux
container: linux-patch-api-rpm:latest
needs: [fmt, clippy, test]
runs-on: fedora
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Install RPM build tools
run: |
dnf install -y rpm-build gcc cargo rust systemd-devel pkg-config
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install build dependencies
run: sudo dnf install -y rpm-build gcc systemd-devel pkg-config
- name: Build release binary
run: cargo build --release
- name: Build RPM package
run: ./build-rpm.sh
run: |
chmod +x build-rpm.sh
./build-rpm.sh
- name: Upload to Gitea Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITEA_TOKEN: ${{ secrets.giteatoken }}
GITEA_API: https://gitea.moon-dragon.us/api/v1
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
FILE=$(ls ~/rpmbuild/RPMS/x86_64/*.rpm 2>/dev/null | head -1)
[ -z "$FILE" ] && echo "No .rpm found" && exit 0
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_API/repos/echo/linux_patch_api/releases/tags/$TAG_NAME" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -z "$RELEASE_ID" ]; then
RESPONSE=$(curl -s -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" "$GITEA_API/repos/echo/linux_patch_api/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
fi
UPLOAD_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST -H "Authorization: token $GITEA_TOKEN" -F "attachment=@$FILE" "$GITEA_API/repos/echo/linux_patch_api/releases/$RELEASE_ID/assets?name=$(basename $FILE)")
HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2)
if [ "$HTTP_CODE" != "201" ] && [ "$HTTP_CODE" != "200" ]; then echo "Upload failed $HTTP_CODE" && exit 1; fi
echo "Successfully uploaded $FILE"
chmod +x scripts/upload-release.sh
./scripts/upload-release.sh "$TAG_NAME" "$FILE"
build-apk:
name: Build Alpine Package
runs-on: linux
container: node:18-alpine
needs: [fmt, clippy, test]
runs-on: alpine
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
run: |
apk add --no-cache curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
source $HOME/.cargo/env
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install build dependencies
run: |
apk add --no-cache musl-dev openssl-dev git abuild gcc elogind-dev
- name: Build APK package
run: ./build-alpine.sh
apk add --no-cache alpine-sdk rust cargo openssl-dev elogind-dev musl-dev git abuild gcc bash curl nodejs
- name: Build release binary
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Build Alpine package
run: |
chmod +x build-alpine.sh
SKIP_CARGO_BUILD=1 ./build-alpine.sh
- name: Upload to Gitea Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITEA_TOKEN: ${{ secrets.giteatoken }}
GITEA_API: https://gitea.moon-dragon.us/api/v1
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
FILE=$(ls releases/*.apk 2>/dev/null | head -1)
[ -z "$FILE" ] && echo "No .apk found" && exit 0
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_API/repos/echo/linux_patch_api/releases/tags/$TAG_NAME" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -z "$RELEASE_ID" ]; then
RESPONSE=$(curl -s -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" "$GITEA_API/repos/echo/linux_patch_api/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
fi
UPLOAD_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST -H "Authorization: token $GITEA_TOKEN" -F "attachment=@$FILE" "$GITEA_API/repos/echo/linux_patch_api/releases/$RELEASE_ID/assets?name=$(basename $FILE)")
HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2)
if [ "$HTTP_CODE" != "201" ] && [ "$HTTP_CODE" != "200" ]; then echo "Upload failed $HTTP_CODE" && exit 1; fi
echo "Successfully uploaded $FILE"
chmod +x scripts/upload-release.sh
./scripts/upload-release.sh "$TAG_NAME" "$FILE"
build-arch:
name: Build Arch Package
runs-on: linux
container: linux-patch-api-arch:latest
needs: [fmt, clippy, test]
runs-on: arch
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install build dependencies
run: |
pacman -Syu --noconfirm rust cargo systemd git base-devel
run: sudo pacman -Syu --noconfirm rust cargo systemd git base-devel
- name: Build release binary
run: cargo build --release
- name: Build Arch package
run: ./build-arch.sh
run: |
chmod +x build-arch.sh
SKIP_CARGO_BUILD=1 ./build-arch.sh
- name: Upload to Gitea Release
if: startsWith(github.ref, 'refs/tags/')
env:
GITEA_TOKEN: ${{ secrets.giteatoken }}
GITEA_API: https://gitea.moon-dragon.us/api/v1
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
FILE=$(ls releases/*.pkg.tar.zst 2>/dev/null | head -1)
[ -z "$FILE" ] && echo "No .pkg.tar.zst found" && exit 0
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_API/repos/echo/linux_patch_api/releases/tags/$TAG_NAME" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -z "$RELEASE_ID" ]; then
RESPONSE=$(curl -s -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" -d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\"}" "$GITEA_API/repos/echo/linux_patch_api/releases")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
fi
UPLOAD_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST -H "Authorization: token $GITEA_TOKEN" -F "attachment=@$FILE" "$GITEA_API/repos/echo/linux_patch_api/releases/$RELEASE_ID/assets?name=$(basename $FILE)")
HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | grep "HTTP_CODE:" | cut -d: -f2)
if [ "$HTTP_CODE" != "201" ] && [ "$HTTP_CODE" != "200" ]; then echo "Upload failed $HTTP_CODE" && exit 1; fi
echo "Successfully uploaded $FILE"
chmod +x scripts/upload-release.sh
./scripts/upload-release.sh "$TAG_NAME" "$FILE"