|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["CI"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-binaries: |
| 11 | + if: > |
| 12 | + github.event.workflow_run.conclusion == 'success' && |
| 13 | + github.event.workflow_run.head_branch == 'master' |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 19 | + node: ["20.x"] |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 25 | + ref: ${{ github.event.workflow_run.head_commit.id }} |
| 26 | + |
| 27 | + - name: Setup pnpm |
| 28 | + uses: pnpm/action-setup@v4 |
| 29 | + with: |
| 30 | + version: 10.x |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: ${{ matrix.node }} |
| 36 | + cache: pnpm |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: pnpm install --frozen-lockfile |
| 40 | + |
| 41 | + - name: Install LAME (Ubuntu) |
| 42 | + if: matrix.os == 'ubuntu-latest' |
| 43 | + run: | |
| 44 | + sudo apt-get update |
| 45 | + sudo apt-get install -y lame |
| 46 | +
|
| 47 | + - name: Install LAME (macOS) |
| 48 | + if: matrix.os == 'macos-latest' |
| 49 | + run: brew install lame |
| 50 | + |
| 51 | + - name: Install LAME (Windows) |
| 52 | + if: matrix.os == 'windows-latest' |
| 53 | + shell: powershell |
| 54 | + run: choco install lame --no-progress -y |
| 55 | + |
| 56 | + - name: Package binary (Unix) |
| 57 | + if: matrix.os != 'windows-latest' |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + set -euo pipefail |
| 61 | + PLATFORM=$(node -p "process.platform") |
| 62 | + ARCH=$(node -p "process.arch") |
| 63 | + BINARY_PATH=$(command -v lame) |
| 64 | + mkdir -p artifacts |
| 65 | + node scripts/package-lame.mjs --binary "$BINARY_PATH" --platform "$PLATFORM" --arch "$ARCH" --out-dir artifacts |
| 66 | +
|
| 67 | + - name: Package binary (Windows) |
| 68 | + if: matrix.os == 'windows-latest' |
| 69 | + shell: powershell |
| 70 | + run: | |
| 71 | + $platform = node -p "process.platform" |
| 72 | + $arch = node -p "process.arch" |
| 73 | + $binary = (Get-Command lame.exe).Source |
| 74 | + New-Item -ItemType Directory -Force -Path artifacts | Out-Null |
| 75 | + node scripts/package-lame.mjs --binary "$binary" --platform "$platform" --arch "$arch" --out-dir artifacts |
| 76 | +
|
| 77 | + - name: Upload artifacts |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: lame-${{ matrix.os }} |
| 81 | + path: artifacts |
| 82 | + |
| 83 | + publish: |
| 84 | + needs: build-binaries |
| 85 | + if: > |
| 86 | + github.event.workflow_run.conclusion == 'success' && |
| 87 | + github.event.workflow_run.head_branch == 'master' |
| 88 | + runs-on: ubuntu-latest |
| 89 | + permissions: |
| 90 | + contents: write |
| 91 | + id-token: write |
| 92 | + steps: |
| 93 | + - name: Checkout |
| 94 | + uses: actions/checkout@v4 |
| 95 | + with: |
| 96 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 97 | + ref: ${{ github.event.workflow_run.head_commit.id }} |
| 98 | + |
| 99 | + - name: Setup pnpm |
| 100 | + uses: pnpm/action-setup@v4 |
| 101 | + with: |
| 102 | + version: 10.x |
| 103 | + |
| 104 | + - name: Setup Node.js |
| 105 | + uses: actions/setup-node@v4 |
| 106 | + with: |
| 107 | + node-version: 22.x |
| 108 | + cache: pnpm |
| 109 | + registry-url: https://registry.npmjs.org |
| 110 | + |
| 111 | + - name: Install dependencies |
| 112 | + run: pnpm install --frozen-lockfile |
| 113 | + |
| 114 | + - name: Download artifacts |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + path: artifacts |
| 118 | + |
| 119 | + - name: Unpack binaries into vendor directory |
| 120 | + run: node scripts/unpack-lame-artifacts.mjs artifacts vendor/lame |
| 121 | + |
| 122 | + - name: Build package |
| 123 | + run: pnpm run build |
| 124 | + |
| 125 | + - name: Publish to npm |
| 126 | + env: |
| 127 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 128 | + run: pnpm publish --access public |
0 commit comments