From 05242a1c7d3bf51d4f3f895ae37cfea465b98552 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Wed, 18 Mar 2026 09:48:16 +0000 Subject: [PATCH] fix(build): replace manual release compilation workflows with tsdeno-based build configuration --- .gitea/workflows/ci.yml | 84 -------------------- .gitea/workflows/npm-publish.yml | 129 ------------------------------- .gitea/workflows/release.yml | 74 ++++-------------- changelog.md | 9 +++ deno.json | 3 +- npmextra.json | 44 +++++++++++ scripts/compile-all.sh | 66 ---------------- ts/00_commitinfo_data.ts | 2 +- 8 files changed, 69 insertions(+), 342 deletions(-) delete mode 100644 .gitea/workflows/ci.yml delete mode 100644 .gitea/workflows/npm-publish.yml delete mode 100755 scripts/compile-all.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml deleted file mode 100644 index 0aea75e..0000000 --- a/.gitea/workflows/ci.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: CI - -on: - push: - branches: - - main - - 'migration/**' - pull_request: - branches: - - main - -jobs: - check: - name: Type Check & Lint - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v2.x - - - name: Check TypeScript types - run: deno check mod.ts - - - name: Lint code - run: deno lint - continue-on-error: true - - - name: Format check - run: deno fmt --check - continue-on-error: true - - build: - name: Build Test (Current Platform) - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v2.x - - - name: Compile for current platform - run: | - echo "Testing compilation for Linux x86_64..." - deno compile --allow-all --no-check \ - --output nupst-test \ - --target x86_64-unknown-linux-gnu mod.ts - - - name: Test binary execution - run: | - chmod +x nupst-test - ./nupst-test --version - ./nupst-test help - - build-all: - name: Build All Platforms - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v2.x - - - name: Compile all platform binaries - run: bash scripts/compile-all.sh - - - name: Upload all binaries as artifact - uses: actions/upload-artifact@v3 - with: - name: nupst-binaries.zip - path: dist/binaries/* - retention-days: 30 diff --git a/.gitea/workflows/npm-publish.yml b/.gitea/workflows/npm-publish.yml deleted file mode 100644 index 3330592..0000000 --- a/.gitea/workflows/npm-publish.yml +++ /dev/null @@ -1,129 +0,0 @@ -name: Publish to npm - -on: - push: - tags: - - 'v*' - -jobs: - npm-publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v2.x - - - name: Setup Node.js for npm publishing - uses: actions/setup-node@v4 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org/' - - - name: Get version from tag - id: version - run: | - VERSION=${GITHUB_REF#refs/tags/} - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT - echo "Publishing version: $VERSION" - - - name: Verify deno.json version matches tag - run: | - DENO_VERSION=$(grep -o '"version": "[^"]*"' deno.json | cut -d'"' -f4) - TAG_VERSION="${{ steps.version.outputs.version_number }}" - echo "deno.json version: $DENO_VERSION" - echo "Tag version: $TAG_VERSION" - if [ "$DENO_VERSION" != "$TAG_VERSION" ]; then - echo "ERROR: Version mismatch!" - echo "deno.json has version $DENO_VERSION but tag is $TAG_VERSION" - exit 1 - fi - - - name: Compile binaries for npm package - run: | - echo "Compiling binaries for npm package..." - deno task compile - echo "" - echo "Binary sizes:" - ls -lh dist/binaries/ - - - name: Generate SHA256 checksums - run: | - cd dist/binaries - sha256sum * > SHA256SUMS - cat SHA256SUMS - cd ../.. - - - name: Sync package.json version - run: | - VERSION="${{ steps.version.outputs.version_number }}" - echo "Syncing package.json to version ${VERSION}..." - npm version ${VERSION} --no-git-tag-version --allow-same-version - echo "package.json version: $(grep '"version"' package.json | head -1)" - - - name: Create npm package - run: | - echo "Creating npm package..." - npm pack - echo "" - echo "Package created:" - ls -lh *.tgz - - - name: Test local installation - run: | - echo "Testing local package installation..." - PACKAGE_FILE=$(ls *.tgz) - npm install -g ${PACKAGE_FILE} - echo "" - echo "Testing nupst command:" - nupst --version || echo "Note: Binary execution may fail in CI environment" - echo "" - echo "Checking installed files:" - npm ls -g @serve.zone/nupst || true - - - name: Publish to npm - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - echo "Publishing to npm registry..." - npm publish --access public - echo "" - echo "✅ Successfully published @serve.zone/nupst to npm!" - echo "" - echo "Package info:" - npm view @serve.zone/nupst - - - name: Verify npm package - run: | - echo "Waiting for npm propagation..." - sleep 30 - echo "" - echo "Verifying published package..." - npm view @serve.zone/nupst - echo "" - echo "Testing installation from npm:" - npm install -g @serve.zone/nupst - echo "" - echo "Package installed successfully!" - which nupst || echo "Binary location check skipped" - - - name: Publish Summary - run: | - echo "================================================" - echo " npm Publish Complete!" - echo "================================================" - echo "" - echo "✅ Package: @serve.zone/nupst" - echo "✅ Version: ${{ steps.version.outputs.version }}" - echo "" - echo "Installation:" - echo " npm install -g @serve.zone/nupst" - echo "" - echo "Registry:" - echo " https://www.npmjs.com/package/@serve.zone/nupst" - echo "" diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index bd24059..5b6c046 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -8,6 +8,8 @@ on: jobs: build-and-release: runs-on: ubuntu-latest + container: + image: code.foss.global/host.today/ht-docker-node:latest steps: - name: Checkout code @@ -20,6 +22,17 @@ jobs: with: deno-version: v2.x + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Enable corepack + run: corepack enable + + - name: Install dependencies + run: pnpm install --ignore-scripts + - name: Get version from tag id: version run: | @@ -41,57 +54,7 @@ jobs: fi - name: Compile binaries for all platforms - run: | - echo "================================================" - echo " NUPST Release Compilation" - echo " Version: ${{ steps.version.outputs.version }}" - echo "================================================" - echo "" - - # Clean up old binaries and create fresh directory - rm -rf dist/binaries - mkdir -p dist/binaries - echo "→ Cleaned old binaries from dist/binaries" - echo "" - - # Linux x86_64 - echo "→ Compiling for Linux x86_64..." - deno compile --allow-all --no-check \ - --output dist/binaries/nupst-linux-x64 \ - --target x86_64-unknown-linux-gnu mod.ts - echo " ✓ Linux x86_64 complete" - - # Linux ARM64 - echo "→ Compiling for Linux ARM64..." - deno compile --allow-all --no-check \ - --output dist/binaries/nupst-linux-arm64 \ - --target aarch64-unknown-linux-gnu mod.ts - echo " ✓ Linux ARM64 complete" - - # macOS x86_64 - echo "→ Compiling for macOS x86_64..." - deno compile --allow-all --no-check \ - --output dist/binaries/nupst-macos-x64 \ - --target x86_64-apple-darwin mod.ts - echo " ✓ macOS x86_64 complete" - - # macOS ARM64 - echo "→ Compiling for macOS ARM64..." - deno compile --allow-all --no-check \ - --output dist/binaries/nupst-macos-arm64 \ - --target aarch64-apple-darwin mod.ts - echo " ✓ macOS ARM64 complete" - - # Windows x86_64 - echo "→ Compiling for Windows x86_64..." - deno compile --allow-all --no-check \ - --output dist/binaries/nupst-windows-x64.exe \ - --target x86_64-pc-windows-msvc mod.ts - echo " ✓ Windows x86_64 complete" - - echo "" - echo "All binaries compiled successfully!" - ls -lh dist/binaries/ + run: mkdir -p dist/binaries && npx tsdeno compile - name: Generate SHA256 checksums run: | @@ -105,7 +68,6 @@ jobs: run: | VERSION="${{ steps.version.outputs.version }}" - # Check if CHANGELOG.md exists if [ ! -f CHANGELOG.md ]; then echo "No CHANGELOG.md found, using default release notes" cat > /tmp/release_notes.md << EOF @@ -133,8 +95,6 @@ jobs: SHA256 checksums are provided in SHA256SUMS.txt EOF else - # Try to extract section for this version from CHANGELOG.md - # This is a simple extraction - adjust based on your CHANGELOG format awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | sed '$d' > /tmp/release_notes.md || cat > /tmp/release_notes.md << EOF ## NUPST $VERSION @@ -158,7 +118,6 @@ jobs: echo "Checking for existing release $VERSION..." - # Try to get existing release by tag EXISTING_RELEASE_ID=$(curl -s \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ "https://code.foss.global/api/v1/repos/serve.zone/nupst/releases/tags/$VERSION" \ @@ -178,9 +137,7 @@ jobs: - name: Create Gitea Release run: | VERSION="${{ steps.version.outputs.version }}" - RELEASE_NOTES=$(cat /tmp/release_notes.md) - # Create the release echo "Creating release for $VERSION..." RELEASE_ID=$(curl -X POST -s \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ @@ -196,7 +153,6 @@ jobs: echo "Release created with ID: $RELEASE_ID" - # Upload binaries as release assets for binary in dist/binaries/*; do filename=$(basename "$binary") echo "Uploading $filename..." @@ -213,12 +169,10 @@ jobs: run: | echo "Cleaning up old releases (keeping only last 3)..." - # Fetch all releases sorted by creation date RELEASES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ "https://code.foss.global/api/v1/repos/serve.zone/nupst/releases" | \ jq -r 'sort_by(.created_at) | reverse | .[3:] | .[].id') - # Delete old releases if [ -n "$RELEASES" ]; then echo "Found releases to delete:" for release_id in $RELEASES; do diff --git a/changelog.md b/changelog.md index 523e3ea..d6a1256 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ # Changelog +## 2026-03-18 - 5.3.2 - fix(build) +replace manual release compilation workflows with tsdeno-based build configuration + +- removes obsolete CI and npm publish workflows +- switches the Deno compile task to use tsdeno +- adds reusable multi-platform compile targets in npmextra.json +- updates the release workflow to install Node.js and pnpm before building binaries +- deletes the custom compile-all.sh script in favor of centralized build tooling + ## 2026-03-15 - 5.3.1 - fix(cli) rename the update command references to upgrade across the CLI and documentation diff --git a/deno.json b/deno.json index bd7835b..39afa67 100644 --- a/deno.json +++ b/deno.json @@ -5,8 +5,7 @@ "nodeModulesDir": "auto", "tasks": { "dev": "deno run --allow-all mod.ts", - "compile": "deno task compile:all", - "compile:all": "bash scripts/compile-all.sh", + "compile": "tsdeno compile", "test": "deno test --allow-all test/", "test:watch": "deno test --allow-all --watch test/", "check": "deno check mod.ts", diff --git a/npmextra.json b/npmextra.json index 6cfb8de..3fcaa78 100644 --- a/npmextra.json +++ b/npmextra.json @@ -16,5 +16,49 @@ "license": "MIT" } }, + "@git.zone/tsdeno": { + "compileTargets": [ + { + "name": "nupst-linux-x64", + "entryPoint": "mod.ts", + "outDir": "dist/binaries", + "target": "x86_64-unknown-linux-gnu", + "permissions": ["--allow-all"], + "noCheck": true + }, + { + "name": "nupst-linux-arm64", + "entryPoint": "mod.ts", + "outDir": "dist/binaries", + "target": "aarch64-unknown-linux-gnu", + "permissions": ["--allow-all"], + "noCheck": true + }, + { + "name": "nupst-macos-x64", + "entryPoint": "mod.ts", + "outDir": "dist/binaries", + "target": "x86_64-apple-darwin", + "permissions": ["--allow-all"], + "noCheck": true + }, + { + "name": "nupst-macos-arm64", + "entryPoint": "mod.ts", + "outDir": "dist/binaries", + "target": "aarch64-apple-darwin", + "permissions": ["--allow-all"], + "noCheck": true + }, + { + "name": "nupst-windows-x64", + "entryPoint": "mod.ts", + "outDir": "dist/binaries", + "target": "x86_64-pc-windows-msvc", + "permissions": ["--allow-all"], + "noCheck": true + } + ] + }, "@ship.zone/szci": {} } diff --git a/scripts/compile-all.sh b/scripts/compile-all.sh deleted file mode 100755 index 4b7f9cb..0000000 --- a/scripts/compile-all.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -set -e - -# Get version from deno.json -VERSION=$(cat deno.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4) -BINARY_DIR="dist/binaries" - -echo "================================================" -echo " NUPST Compilation Script" -echo " Version: ${VERSION}" -echo "================================================" -echo "" -echo "Compiling for all supported platforms..." -echo "" - -# Clean up old binaries and create fresh directory -rm -rf "$BINARY_DIR" -mkdir -p "$BINARY_DIR" -echo "→ Cleaned old binaries from $BINARY_DIR" -echo "" - -# Linux x86_64 -echo "→ Compiling for Linux x86_64..." -deno compile --allow-all --no-check --output "$BINARY_DIR/nupst-linux-x64" \ - --target x86_64-unknown-linux-gnu mod.ts -echo " ✓ Linux x86_64 complete" -echo "" - -# Linux ARM64 -echo "→ Compiling for Linux ARM64..." -deno compile --allow-all --no-check --output "$BINARY_DIR/nupst-linux-arm64" \ - --target aarch64-unknown-linux-gnu mod.ts -echo " ✓ Linux ARM64 complete" -echo "" - -# macOS x86_64 -echo "→ Compiling for macOS x86_64..." -deno compile --allow-all --no-check --output "$BINARY_DIR/nupst-macos-x64" \ - --target x86_64-apple-darwin mod.ts -echo " ✓ macOS x86_64 complete" -echo "" - -# macOS ARM64 -echo "→ Compiling for macOS ARM64..." -deno compile --allow-all --no-check --output "$BINARY_DIR/nupst-macos-arm64" \ - --target aarch64-apple-darwin mod.ts -echo " ✓ macOS ARM64 complete" -echo "" - -# Windows x86_64 -echo "→ Compiling for Windows x86_64..." -deno compile --allow-all --no-check --output "$BINARY_DIR/nupst-windows-x64.exe" \ - --target x86_64-pc-windows-msvc mod.ts -echo " ✓ Windows x86_64 complete" -echo "" - -echo "================================================" -echo " Compilation Summary" -echo "================================================" -echo "" -ls -lh "$BINARY_DIR/" | tail -n +2 -echo "" -echo "✓ All binaries compiled successfully!" -echo "" -echo "Binary location: $BINARY_DIR/" -echo "" diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index c048fc0..de771b4 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@serve.zone/nupst', - version: '5.3.1', + version: '5.3.2', description: 'Network UPS Shutdown Tool - Monitor SNMP-enabled UPS devices and orchestrate graceful system shutdowns during power emergencies' }