name: Build and test asset on: schedule: - cron: '0 10 * * 1' # every Monday at 10:00 UTC workflow_dispatch: inputs: versions: description: 'Node.js version(s) as JSON array' required: true default: '[ "lts/*", "22", "24" ]' pull_request: branches: [ master ] push: tags: [ '*' ] jobs: build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ windows-latest, macos-latest, ubuntu-latest ] # Use the input versions if provided, otherwise fall back to default version: ${{ fromJSON(inputs.versions || '[ "lts/*", "22", "24" ]') }} env: NEXE_ASSET: ${{ github.workspace }}/nexe-asset NEXE_TMP_CACHE_PATH: ${{ github.workspace }}/nexe-tmp NEXE_TMP: ${{ github.workspace }}/nexe-tmp/standard CCACHE_COMPRESS: '1' ErrorView: NormalView steps: # Checkout repository - uses: actions/checkout@v4 # Set up Node.js (using matrix version) - uses: actions/setup-node@v4 with: node-version: ${{ matrix.version }} # Record the exact Node.js version for later use (cross‑platform) - name: Record exact Node.js version shell: bash run: echo "NODEJS_VERSION=$(node -p process.versions.node)" >> $GITHUB_ENV # Install Node dependencies - run: npm ci # Python may be needed for native addons - uses: actions/setup-python@v5 with: python-version: '3.9' # Windows: install NASM (required for some native modules) - if: matrix.os == 'windows-latest' run: choco install nasm # Ubuntu: update package lists (kept for safety, can be removed if not needed) - if: matrix.os == 'ubuntu-latest' run: sudo apt-get update # Linux/macOS: enable compiler caching with ccache - if: matrix.os != 'windows-latest' uses: hendrikmuhs/ccache-action@v1.2 with: create-symlink: true key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.version }} # Windows: adjust asset name and suffix - if: matrix.os == 'windows-latest' shell: bash run: | echo "NEXE_ASSET=${NEXE_ASSET}.exe" >> $GITHUB_ENV echo "EXECUTABLE_SUFFIX=.exe" >> $GITHUB_ENV # Main build & test (asset + integration) - name: Build and test asset run: node tasks/asset-build && node tasks/asset-test-build && npm run test:integration:run # Rename the built asset to include target platform info - name: Update release artifact name shell: bash run: | nexe_target="$(node -p 'require("./lib/target").getTarget().toString()')" echo "NEXE_TARGET=${nexe_target}" >> $GITHUB_ENV artefact_name="nexe-asset-${nexe_target}" mv "${NEXE_ASSET}" "${artefact_name}" echo "NEXE_ASSET=${artefact_name}" >> $GITHUB_ENV # Upload main asset - name: Upload asset artifact uses: actions/upload-artifact@v4 with: name: ${{ env.NEXE_ASSET }} path: ${{ env.NEXE_ASSET }} if-no-files-found: error # Upload integration test binary - name: Upload integration test artifact uses: actions/upload-artifact@v4 with: name: integration-tests-${{ env.NEXE_TARGET }}${{ env.EXECUTABLE_SUFFIX }} path: integration-tests${{ env.EXECUTABLE_SUFFIX }} if-no-files-found: error # If this is a tag push, attach the asset to the release - if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v2 with: fail_on_unmatched_files: true prerelease: true files: ${{ env.NEXE_ASSET }} # Extra step for Ubuntu: build static (musl) version - if: matrix.os == 'ubuntu-latest' name: musl static build shell: bash run: | # Determine musl target and set up environment nexe_target="$(node -p 'require("./lib/target").getTarget({ platform: "static" }).toString()')" echo "NEXE_TARGET=${nexe_target}" >> $GITHUB_ENV artefact_name="nexe-asset-${nexe_target}" export NEXE_ASSET="${artefact_name}" echo "NEXE_ASSET=${NEXE_ASSET}" >> $GITHUB_ENV export MUSL_BUILD=yes NEXE_TMP="${NEXE_TMP_CACHE_PATH}/musl" # Set up cross‑compiler with ccache eval $(npx -p node-musl musl-exports) export CC="ccache ${CC}" CXX="ccache ${CXX}" LD="ccache ${LD}" # Build and test musl version node tasks/asset-build node tasks/asset-test-build npm run test:integration:run # Upload musl asset - if: matrix.os == 'ubuntu-latest' name: Upload musl asset uses: actions/upload-artifact@v4 with: name: ${{ env.NEXE_ASSET }} path: ${{ env.NEXE_ASSET }} if-no-files-found: error # Upload musl integration test binary - if: matrix.os == 'ubuntu-latest' name: Upload musl integration test uses: actions/upload-artifact@v4 with: name: integration-tests-${{ env.NEXE_TARGET }}${{ env.EXECUTABLE_SUFFIX }} path: integration-tests if-no-files-found: error # If this is a tag push, also attach the musl asset to the release - if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' uses: softprops/action-gh-release@v2 with: fail_on_unmatched_files: true prerelease: true files: ${{ env.NEXE_ASSET }}