diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index cd70172..2f47660 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -11,39 +11,31 @@ env: CARGO_TERM_COLOR: always jobs: - # --------------------------------------------------------------------------- - # Job 1: Rust Backend - Build + Test - # --------------------------------------------------------------------------- - build-backend: + build-and-package: runs-on: ubuntu-latest container: image: ubuntu:24.04 steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install build dependencies + - name: Install system dependencies run: | apt-get update -qq apt-get install -y --no-install-recommends \ - curl pkg-config libssl-dev ca-certificates - # Install Rust toolchain + curl pkg-config libssl-dev ca-certificates \ + git nodejs npm dpkg-dev python3 + + - name: Checkout repository + run: | + git clone "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" . + git checkout "$GITHUB_SHA" + + - name: Install Rust toolchain + run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y . "$HOME/.cargo/env" rustup default stable - echo "$HOME/.cargo/bin" >> $GITHUB_PATH + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" - - name: Cache Cargo registry - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: cargo-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo- - - - name: Build (release) + - name: Build Rust backend (release) run: | . "$HOME/.cargo/env" cargo build --release @@ -58,26 +50,7 @@ jobs: strip target/release/pm-web strip target/release/pm-worker - - name: Upload backend artifacts - uses: actions/upload-artifact@v3 - with: - name: backend-binaries - path: | - target/release/pm-web - target/release/pm-worker - - # --------------------------------------------------------------------------- - # Job 2: Frontend - Build - # --------------------------------------------------------------------------- - build-frontend: - runs-on: ubuntu-latest - container: - image: node:20-bookworm - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install dependencies + - name: Install frontend dependencies working-directory: frontend run: npm ci @@ -85,44 +58,6 @@ jobs: working-directory: frontend run: npm run build - - name: Upload frontend artifacts - uses: actions/upload-artifact@v3 - with: - name: frontend-dist - path: frontend/dist/ - - # --------------------------------------------------------------------------- - # Job 3: Package .deb - # --------------------------------------------------------------------------- - build-deb: - needs: [build-backend, build-frontend] - runs-on: ubuntu-latest - container: - image: ubuntu:24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install packaging tools - run: | - apt-get update -qq - apt-get install -y --no-install-recommends dpkg-dev curl ca-certificates - - - name: Download backend artifacts - uses: actions/download-artifact@v3 - with: - name: backend-binaries - path: target/release/ - - - name: Download frontend artifacts - uses: actions/download-artifact@v3 - with: - name: frontend-dist - path: frontend/dist/ - - - name: Make binaries executable - run: chmod 755 target/release/pm-web target/release/pm-worker - - name: Determine version id: version run: | @@ -171,7 +106,7 @@ jobs: cp debian/postrm "${BUILD_DIR}/DEBIAN/postrm" chmod 755 "${BUILD_DIR}/DEBIAN/postinst" "${BUILD_DIR}/DEBIAN/prerm" "${BUILD_DIR}/DEBIAN/postrm" - # Generate control file with computed version and size + # Generate control file INSTALLED_SIZE=$(du -sk "${BUILD_DIR}" | cut -f1) cat > "${BUILD_DIR}/DEBIAN/control" <> "$GITHUB_OUTPUT" + echo "Built: ${DEB_NAME}" + du -h "${DEB_NAME}" - name: Verify package run: | @@ -202,27 +138,20 @@ jobs: echo "=== Package Size ===" du -h "${DEB_NAME}" - - name: Upload .deb artifact - uses: actions/upload-artifact@v3 - with: - name: deb-package - path: linux-patch-manager_*.deb - - - name: Create Gitea Release + - name: Create Gitea Release (tags only) if: startsWith(github.ref, 'refs/tags/v') run: | DEB_NAME=$(ls linux-patch-manager_*.deb) VERSION="${{ steps.version.outputs.version }}" - # Use Gitea API to create release and upload asset + # Create release via Gitea API curl -s -X POST \ "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases" \ -H "Authorization: token ${GITHUB_TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\": \"${GITHUB_REF_NAME}\", \"title\": \"Release ${VERSION}\", \"body\": \"Automated build from tag ${GITHUB_REF_NAME}.\"}" \ -o release.json - # Extract release ID + # Extract release ID and upload .deb RELEASE_ID=$(python3 -c "import json; print(json.load(open('release.json'))['id'])") - # Upload .deb as release asset curl -s -X POST \ "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" \ -H "Authorization: token ${GITHUB_TOKEN}" \