name: Release Build on: push: tags: - 'v*' workflow_dispatch: permissions: contents: write jobs: build: name: Build ${{ matrix.os }} runs-on: ${{ matrix.runner }} strategy: matrix: include: - os: linux runner: ubuntu-latest targets: node18-linux-x64,node18-linux-arm64 - os: macos runner: macos-latest targets: node18-macos-x64,node18-macos-arm64 - os: windows runner: windows-latest targets: node18-win-x64 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' cache: 'npm' - name: Install dependencies run: npm ci - name: Create dist directory run: mkdir -p dist - name: Build for ${{ matrix.os }} run: | npm run build npx pkg dist/bundle.cjs --targets ${{ matrix.targets }} --compress GZip --out-path dist/ - name: List built files (debug - Unix) if: matrix.os != 'windows' run: ls -lah dist/ - name: List built files (debug - Windows) if: matrix.os == 'windows' shell: pwsh run: Get-ChildItem -Path dist/ | Format-Table -AutoSize - name: Rename executables (Linux) if: matrix.os == 'linux' run: | [ -f dist/bundle-x64 ] && mv dist/bundle-x64 dist/httptoolkit-patcher-linux-x64 [ -f dist/bundle-arm64 ] && mv dist/bundle-arm64 dist/httptoolkit-patcher-linux-arm64 rm -f dist/bundle dist/bundle.cjs 2>/dev/null || true - name: Rename executables (macOS) if: matrix.os == 'macos' run: | [ -f dist/bundle-x64 ] && mv dist/bundle-x64 dist/httptoolkit-patcher-macos-x64 [ -f dist/bundle-arm64 ] && mv dist/bundle-arm64 dist/httptoolkit-patcher-macos-arm64 rm -f dist/bundle dist/bundle.cjs 2>/dev/null || true - name: Rename executables (Windows) if: matrix.os == 'windows' shell: pwsh run: | if (Test-Path dist/bundle.exe) { Move-Item -Force dist/bundle.exe dist/httptoolkit-patcher.exe } if (Test-Path dist/bundle-x64.exe) { Move-Item -Force dist/bundle-x64.exe dist/httptoolkit-patcher-win-x64.exe } Remove-Item -Force dist/bundle.cjs -ErrorAction SilentlyContinue - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: binaries-${{ matrix.os }} path: dist/* release: name: Create Release needs: build runs-on: ubuntu-latest steps: - name: Download all artifacts uses: actions/download-artifact@v4 with: pattern: binaries-* path: artifacts merge-multiple: true - name: Prepare release files run: | mkdir -p release cp artifacts/* release/ 2>/dev/null || find artifacts -type f -exec cp {} release/ \; ls -lah release/ - name: Extract version from tag id: get_version run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - name: Create Release uses: softprops/action-gh-release@v1 with: files: release/* draft: false prerelease: false generate_release_notes: true name: Release ${{ steps.get_version.outputs.VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}