|
| 1 | +name: Publish Test Package |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: npm dist-tag for the test package |
| 8 | + required: true |
| 9 | + default: beta |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - alpha |
| 13 | + - beta |
| 14 | + - next |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-foreground: |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + - runner: ubuntu-latest |
| 26 | + package_target: linux-x64-gnu |
| 27 | + setup: "" |
| 28 | + cc: cc |
| 29 | + ldflags: -Wl,--gc-sections |
| 30 | + - runner: ubuntu-latest |
| 31 | + package_target: linux-x64-musl |
| 32 | + setup: sudo apt-get update && sudo apt-get install -y musl-tools |
| 33 | + cc: musl-gcc |
| 34 | + ldflags: -Wl,--gc-sections |
| 35 | + - runner: ubuntu-24.04-arm |
| 36 | + package_target: linux-arm64-gnu |
| 37 | + setup: "" |
| 38 | + cc: cc |
| 39 | + ldflags: -Wl,--gc-sections |
| 40 | + - runner: macos-15-intel |
| 41 | + package_target: darwin-x64 |
| 42 | + setup: "" |
| 43 | + cc: cc |
| 44 | + ldflags: -Wl,-dead_strip |
| 45 | + - runner: macos-15 |
| 46 | + package_target: darwin-arm64 |
| 47 | + setup: "" |
| 48 | + cc: cc |
| 49 | + ldflags: -Wl,-dead_strip |
| 50 | + runs-on: ${{ matrix.runner }} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v6.0.3 |
| 53 | + |
| 54 | + - name: Install target dependencies |
| 55 | + if: matrix.setup |
| 56 | + run: ${{ matrix.setup }} |
| 57 | + |
| 58 | + - name: Build foreground helper |
| 59 | + env: |
| 60 | + CC: ${{ matrix.cc }} |
| 61 | + LDFLAGS: ${{ matrix.ldflags }} |
| 62 | + run: | |
| 63 | + mkdir -p "bin/${{ matrix.package_target }}" |
| 64 | + "$CC" -Os -fdata-sections -ffunction-sections \ |
| 65 | + native/foreground/foreground.c \ |
| 66 | + $LDFLAGS \ |
| 67 | + -o "bin/${{ matrix.package_target }}/foreground" |
| 68 | + strip "bin/${{ matrix.package_target }}/foreground" || true |
| 69 | + chmod +x "bin/${{ matrix.package_target }}/foreground" |
| 70 | + ls -lh "bin/${{ matrix.package_target }}/foreground" |
| 71 | +
|
| 72 | + - uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: foreground-${{ matrix.package_target }} |
| 75 | + path: bin/${{ matrix.package_target }}/foreground |
| 76 | + if-no-files-found: error |
| 77 | + |
| 78 | + publish-test: |
| 79 | + needs: build-foreground |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v6.0.3 |
| 83 | + |
| 84 | + - uses: actions/setup-node@v6.4.0 |
| 85 | + with: |
| 86 | + node-version: 24 |
| 87 | + registry-url: https://registry.npmjs.org |
| 88 | + |
| 89 | + - uses: pnpm/action-setup@v6.0.8 |
| 90 | + with: |
| 91 | + run_install: true |
| 92 | + |
| 93 | + - uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + pattern: foreground-* |
| 96 | + path: bin-artifacts |
| 97 | + |
| 98 | + - name: Install foreground helper artifacts |
| 99 | + run: | |
| 100 | + mkdir -p bin |
| 101 | + for artifact in bin-artifacts/foreground-*; do |
| 102 | + target="${artifact##*/foreground-}" |
| 103 | + mkdir -p "bin/$target" |
| 104 | + cp "$artifact/foreground" "bin/$target/foreground" |
| 105 | + chmod +x "bin/$target/foreground" |
| 106 | + done |
| 107 | + find bin -maxdepth 2 -type f -print |
| 108 | +
|
| 109 | + - name: Set timestamp prerelease version |
| 110 | + id: test-version |
| 111 | + env: |
| 112 | + TEST_TAG: ${{ inputs.tag }} |
| 113 | + run: | |
| 114 | + timestamp="$(date -u +%Y%m%d%H%M%S)" |
| 115 | + version="$(TIMESTAMP="$timestamp" node -e "const fs=require('fs'); const p=require('./package.json'); const base=p.version.split('-')[0]; p.version=base+'-'+process.env.TEST_TAG+'.'+process.env.TIMESTAMP; fs.writeFileSync('package.json', JSON.stringify(p, null, 2)+'\n'); console.log(p.version)")" |
| 116 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 117 | + echo "Prepared test version: $version" |
| 118 | +
|
| 119 | + - name: Build package |
| 120 | + run: pnpm run build |
| 121 | + |
| 122 | + - name: Publish test package |
| 123 | + env: |
| 124 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 125 | + run: npm publish --tag "${{ inputs.tag }}" |
| 126 | + |
| 127 | + - name: Summary |
| 128 | + run: | |
| 129 | + echo "Published lockfile-conflicts@${{ steps.test-version.outputs.version }} with tag ${{ inputs.tag }}" >> "$GITHUB_STEP_SUMMARY" |
| 130 | + echo "Install with: npm install lockfile-conflicts@${{ inputs.tag }}" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments