0.2.0 #177
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish | |
| on: | |
| push: | |
| branches: [main, develop] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| env: | |
| HAMLIB_VERSION: '4.6.5' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: linux-x64 | |
| - os: ubuntu-24.04-arm | |
| target: linux-arm64 | |
| - os: macos-latest | |
| target: darwin-arm64 | |
| - os: macos-15-intel | |
| target: darwin-x64 | |
| - os: windows-latest | |
| target: win32-x64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install Python setuptools (for node-gyp) | |
| run: pip3 install setuptools --break-system-packages || pip3 install setuptools || true | |
| - name: Install system dependencies (Linux) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y autoconf automake libtool pkg-config patchelf | |
| sudo apt-get install -y libusb-1.0-0 libindi1 || true | |
| - name: Install system dependencies (macOS) | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| brew install autoconf automake libtool dylibbundler | |
| pip3 install setuptools --break-system-packages || true | |
| - name: Setup Windows Hamlib | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| $ver = $env:HAMLIB_VERSION | |
| $zipUrl = "https://github.com/Hamlib/Hamlib/releases/download/$ver/hamlib-w64-$ver.zip" | |
| $zipPath = Join-Path $env:RUNNER_TEMP "hamlib-w64-$ver.zip" | |
| Write-Host "Downloading Hamlib $ver..." | |
| Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath | |
| $dest = Join-Path $env:GITHUB_WORKSPACE 'hamlib' | |
| if (Test-Path $dest) { Remove-Item -Recurse -Force $dest } | |
| Add-Type -AssemblyName System.IO.Compression.FileSystem | |
| [System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $dest) | |
| $root = $dest | |
| if (!(Test-Path (Join-Path $root 'bin'))) { | |
| $child = Get-ChildItem -Path $dest -Directory | Select-Object -First 1 | |
| if ($null -ne $child) { $root = $child.FullName } | |
| } | |
| Write-Host "HAMLIB root: $root" | |
| "HAMLIB_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: Setup MSYS2 MinGW (Windows) | |
| if: matrix.os == 'windows-latest' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| location: D:\msys2 | |
| install: mingw-w64-x86_64-gcc mingw-w64-x86_64-binutils | |
| - name: Setup MSVC (Windows) | |
| if: matrix.os == 'windows-latest' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Install Node.js dependencies | |
| run: npm ci --ignore-scripts | |
| - name: Build shim DLL (Windows) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| env: | |
| MINGW_CC: D:\msys2\msys64\mingw64\bin\gcc.exe | |
| run: | | |
| $env:Path = "D:\msys2\msys64\mingw64\bin;$env:Path" | |
| node scripts/build-shim.js --verbose | |
| - name: Build (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: npm run build:all -- --skip-hamlib --skip-shim --minimal | |
| - name: Build (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: npm run build:all -- --minimal | |
| - name: Run tests | |
| run: | | |
| node test/test_loader.js | |
| node test/test_ci_functional.js | |
| - name: Upload prebuilds | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prebuilt-${{ matrix.target }} | |
| path: prebuilds/ | |
| retention-days: 7 | |
| publish: | |
| name: Publish | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: all-artifacts | |
| - name: Organize prebuilds | |
| run: | | |
| mkdir -p prebuilds | |
| for dir in all-artifacts/prebuilt-*/; do | |
| [ -d "$dir" ] && cp -r "$dir"/* prebuilds/ | |
| done | |
| - name: Validate prebuilds | |
| run: | | |
| for p in linux-x64 linux-arm64 darwin-arm64 darwin-x64 win32-x64; do | |
| test -f "prebuilds/$p/node.napi.node" || { echo "Missing: $p"; exit 1; } | |
| done | |
| echo "All 5 platform prebuilds verified." | |
| find prebuilds -name "*.node" -exec ls -la {} \; | |
| - run: npm ci --ignore-scripts | |
| - run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| for dir in prebuilds/*/; do | |
| platform=$(basename "$dir") | |
| tar -czf "node-hamlib-${VERSION}-${platform}.tar.gz" -C prebuilds "$platform" | |
| done | |
| gh release create "$VERSION" --title "Node-HamLib $VERSION" --generate-notes \ | |
| node-hamlib-${VERSION}-*.tar.gz |