|
| 1 | +name: Publish package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + new-version: |
| 9 | + description: New version to be published, overrides tag |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | + npm-tag: |
| 14 | + description: NPM tag |
| 15 | + required: true |
| 16 | + default: latest |
| 17 | + type: choice |
| 18 | + options: |
| 19 | + - latest |
| 20 | + - next |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + include: |
| 27 | + - os: ubuntu-20.04 |
| 28 | + arch: linux-x64-glibc |
| 29 | + - os: ubuntu-22.04-arm |
| 30 | + arch: linux-arm64-glibc |
| 31 | + - os: macos-13 |
| 32 | + arch: darwin-x64 |
| 33 | + - os: macos-14 |
| 34 | + arch: darwin-arm64 |
| 35 | + - os: windows-2019 |
| 36 | + arch: win32-x64 |
| 37 | + |
| 38 | + name: Build for ${{ matrix.arch }} |
| 39 | + runs-on: ${{ matrix.os }} |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + submodules: true |
| 46 | + |
| 47 | + - name: Use Node.js 20 |
| 48 | + uses: actions/setup-node@v4 |
| 49 | + with: |
| 50 | + cache: npm |
| 51 | + node-version: 20 |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + run: npm ci |
| 55 | + |
| 56 | + - name: Prebuild |
| 57 | + run: npm run build |
| 58 | + |
| 59 | + - name: Upload artifacts |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: prebuild-${{ matrix.arch }} |
| 63 | + path: prebuilds/**/*.node |
| 64 | + |
| 65 | + build-linux-musl: |
| 66 | + strategy: |
| 67 | + matrix: |
| 68 | + include: |
| 69 | + - os: ubuntu-20.04 |
| 70 | + arch: x64 |
| 71 | + - os: ubuntu-22.04-arm |
| 72 | + arch: arm64 |
| 73 | + |
| 74 | + name: Build for linux-${{ matrix.arch }}-musl |
| 75 | + runs-on: ${{ matrix.os }} |
| 76 | + |
| 77 | + container: |
| 78 | + image: node:20-alpine |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Install build deps |
| 82 | + run: apk add --no-cache g++ git make python3 |
| 83 | + |
| 84 | + - name: Checkout |
| 85 | + uses: actions/checkout@v4 |
| 86 | + with: |
| 87 | + submodules: true |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + run: npm ci |
| 91 | + |
| 92 | + - name: Prebuild |
| 93 | + run: npm run build |
| 94 | + |
| 95 | + - name: Upload artifacts |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: prebuild-linux-${{ matrix.arch }}-musl |
| 99 | + path: prebuilds/**/*.node |
| 100 | + |
| 101 | + build-freebsd-x64: |
| 102 | + name: Build for freebsd-x64 |
| 103 | + runs-on: ubuntu-latest |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout |
| 107 | + uses: actions/checkout@v4 |
| 108 | + with: |
| 109 | + submodules: true |
| 110 | + |
| 111 | + - name: Prebuild |
| 112 | + uses: vmactions/freebsd-vm@v1 |
| 113 | + with: |
| 114 | + prepare: | |
| 115 | + pkg install -y gmake python3 npm-node20 |
| 116 | + run: | |
| 117 | + npm ci |
| 118 | + npm run build |
| 119 | + sync: sshfs |
| 120 | + |
| 121 | + - name: Upload artifacts |
| 122 | + uses: actions/upload-artifact@v4 |
| 123 | + with: |
| 124 | + name: prebuild-freebsd-x64 |
| 125 | + path: prebuilds/**/*.node |
| 126 | + |
| 127 | + publish: |
| 128 | + name: Upload package artifact |
| 129 | + runs-on: ubuntu-latest |
| 130 | + |
| 131 | + needs: |
| 132 | + - build |
| 133 | + - build-freebsd-x64 |
| 134 | + - build-linux-musl |
| 135 | + |
| 136 | + steps: |
| 137 | + - name: Checkout |
| 138 | + uses: actions/checkout@v4 |
| 139 | + with: |
| 140 | + submodules: true |
| 141 | + |
| 142 | + - name: Setup npm with Node.js 20 |
| 143 | + uses: actions/setup-node@v4 |
| 144 | + with: |
| 145 | + cache: npm |
| 146 | + node-version: 20 |
| 147 | + token: ${{ secrets.NPM_TOKEN }} |
| 148 | + registry-url: 'https://registry.npmjs.org' |
| 149 | + |
| 150 | + - name: Install dependencies |
| 151 | + run: npm ci --ignore-scripts |
| 152 | + |
| 153 | + - name: Download artifacts |
| 154 | + id: download-artifact |
| 155 | + uses: actions/download-artifact@v4 |
| 156 | + |
| 157 | + - name: Move prebuild artifacts |
| 158 | + run: mkdir prebuilds && cp --recursive prebuild-*/* prebuilds/ |
| 159 | + |
| 160 | + - name: Pack package |
| 161 | + run: npm pack |
| 162 | + |
| 163 | + - name: Upload package artifact |
| 164 | + uses: actions/upload-artifact@v4 |
| 165 | + with: |
| 166 | + path: '*.tgz' |
0 commit comments