|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + release-command: |
| 7 | + description: 'The command that will release packages as part of the final step' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + secrets: |
| 11 | + GHCR_TOKEN: |
| 12 | + required: true |
| 13 | + NPM_TOKEN: |
| 14 | + required: true |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read # for actions/checkout |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-macos-windows: |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + - name: aarch64-apple-darwin |
| 26 | + os: macos-latest |
| 27 | + target: aarch64-apple-darwin |
| 28 | + |
| 29 | + - name: macos-latest |
| 30 | + os: macos-latest |
| 31 | + |
| 32 | + - name: windows-latest |
| 33 | + os: windows-latest |
| 34 | + name: ${{ matrix.name }} |
| 35 | + runs-on: ${{ matrix.os }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - name: Install Rust |
| 39 | + uses: dtolnay/rust-toolchain@master |
| 40 | + with: |
| 41 | + toolchain: stable |
| 42 | + target: ${{ matrix.target }} |
| 43 | + - uses: bahmutov/[email protected] |
| 44 | + - uses: Swatinem/rust-cache@v2 |
| 45 | + with: |
| 46 | + shared-key: ${{ matrix.name }} |
| 47 | + - name: Remove CommandLineTools SDKs |
| 48 | + if: ${{ matrix.target == 'aarch64-apple-darwin' }} |
| 49 | + run: sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; |
| 50 | + - name: Build native packages |
| 51 | + run: yarn build-native-release |
| 52 | + env: |
| 53 | + RUST_TARGET: ${{ matrix.target }} |
| 54 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 55 | + if: ${{ runner.os == 'macOS' }} |
| 56 | + run: strip -x packages/*/*/*.node # Must use -x on macOS. This produces larger results on linux. |
| 57 | + - name: Upload artifacts |
| 58 | + uses: actions/upload-artifact@v3 |
| 59 | + with: |
| 60 | + name: bindings-${{ matrix.name }} |
| 61 | + path: packages/*/*/*.node |
| 62 | + - name: Debug |
| 63 | + if: ${{ runner.os == 'macOS' }} |
| 64 | + run: ls -l packages/*/*/*.node |
| 65 | + - name: Smoke test |
| 66 | + if: ${{ !matrix.target }} |
| 67 | + run: node -e "require('@parcel/rust')" |
| 68 | + |
| 69 | + build-linux-gnu-x64: |
| 70 | + name: linux-gnu-x64 |
| 71 | + runs-on: ubuntu-20.04 |
| 72 | + container: |
| 73 | + image: docker.io/mischnic/centos7-node16 |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v3 |
| 76 | + - name: Install yarn |
| 77 | + run: npm install --global yarn@1 |
| 78 | + - name: Install Rust |
| 79 | + uses: actions-rs/toolchain@v1 |
| 80 | + with: |
| 81 | + toolchain: stable |
| 82 | + profile: minimal |
| 83 | + override: true |
| 84 | + - uses: bahmutov/[email protected] |
| 85 | + - name: Build native packages |
| 86 | + run: yarn build-native-release |
| 87 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 88 | + run: strip packages/*/*/*.node |
| 89 | + - name: Upload artifacts |
| 90 | + uses: actions/upload-artifact@v3 |
| 91 | + with: |
| 92 | + name: bindings-linux-gnu-x64 |
| 93 | + path: packages/*/*/*.node |
| 94 | + - name: debug |
| 95 | + run: ls -l packages/*/*/*.node |
| 96 | + - name: Smoke test |
| 97 | + run: node -e 'require("@parcel/rust")' |
| 98 | + |
| 99 | + build-linux-gnu-arm: |
| 100 | + strategy: |
| 101 | + fail-fast: false |
| 102 | + matrix: |
| 103 | + include: |
| 104 | + - target: arm-unknown-linux-gnueabihf |
| 105 | + arch: armhf |
| 106 | + strip: arm-linux-gnueabihf-strip |
| 107 | + cflags: -mfpu=neon |
| 108 | + - target: aarch64-unknown-linux-gnu |
| 109 | + arch: arm64 |
| 110 | + strip: aarch64-linux-gnu-strip |
| 111 | + cflags: '' |
| 112 | + name: ${{ matrix.target }} |
| 113 | + runs-on: ubuntu-20.04 |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v4 |
| 116 | + - name: Install Rust |
| 117 | + uses: dtolnay/rust-toolchain@master |
| 118 | + with: |
| 119 | + toolchain: stable |
| 120 | + target: ${{ matrix.target }} |
| 121 | + - name: Install cross compile toolchains |
| 122 | + run: | |
| 123 | + sudo apt-get update |
| 124 | + sudo apt-get install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y |
| 125 | + - uses: bahmutov/[email protected] |
| 126 | + - uses: Swatinem/rust-cache@v2 |
| 127 | + with: |
| 128 | + shared-key: ${{ matrix.target }} |
| 129 | + - name: Build native packages |
| 130 | + run: yarn build-native-release |
| 131 | + env: |
| 132 | + RUST_TARGET: ${{ matrix.target }} |
| 133 | + CFLAGS: ${{ matrix.cflags }} |
| 134 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 135 | + run: ${{ matrix.strip }} packages/*/*/*.node |
| 136 | + - name: Upload artifacts |
| 137 | + uses: actions/upload-artifact@v3 |
| 138 | + with: |
| 139 | + name: bindings-${{ matrix.target }} |
| 140 | + path: packages/*/*/*.node |
| 141 | + - name: debug |
| 142 | + run: ls -l packages/*/*/*.node |
| 143 | + - name: Configure binfmt-support |
| 144 | + run: docker run --rm --privileged multiarch/qemu-user-static:register --reset |
| 145 | + - name: Smoke test |
| 146 | + uses: addnab/docker-run-action@v1 |
| 147 | + with: |
| 148 | + image: ghcr.io/devongovett/multiarch-node:node14-${{ matrix.arch }}-focal |
| 149 | + options: -v ${{github.workspace}}:/work |
| 150 | + run: cd /work && node -e "require('@parcel/rust')" |
| 151 | + |
| 152 | + build-linux-musl: |
| 153 | + strategy: |
| 154 | + fail-fast: false |
| 155 | + matrix: |
| 156 | + include: |
| 157 | + - target: x86_64-unknown-linux-musl |
| 158 | + strip: strip |
| 159 | + cflags: -msse4.2 |
| 160 | + arch: x86_64 |
| 161 | + - target: aarch64-unknown-linux-musl |
| 162 | + strip: aarch64-linux-musl-strip |
| 163 | + cflags: '' |
| 164 | + arch: aarch64 |
| 165 | + name: ${{ matrix.target }} |
| 166 | + runs-on: ubuntu-20.04 |
| 167 | + container: |
| 168 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust@sha256:5a99e45446355d25c20e95d35231d84e9ce472280d8c0b1be53281bade905f09 |
| 169 | + credentials: |
| 170 | + username: ${{ github.actor }} |
| 171 | + password: ${{ secrets.GHCR_TOKEN }} |
| 172 | + steps: |
| 173 | + - uses: actions/checkout@v4 |
| 174 | + - name: Install build tools |
| 175 | + run: apk add --no-cache python3 make gcc g++ musl-dev curl |
| 176 | + - name: Install Rust |
| 177 | + uses: dtolnay/rust-toolchain@master |
| 178 | + with: |
| 179 | + toolchain: stable |
| 180 | + target: ${{ matrix.target }} |
| 181 | + - uses: bahmutov/[email protected] |
| 182 | + - name: Build native packages |
| 183 | + run: yarn build-native-release |
| 184 | + env: |
| 185 | + RUST_TARGET: ${{ matrix.target }} |
| 186 | + CFLAGS: ${{ matrix.cflags }} |
| 187 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 188 | + run: ${{ matrix.strip }} packages/*/*/*.node |
| 189 | + - name: Upload artifacts |
| 190 | + uses: actions/upload-artifact@v3 |
| 191 | + with: |
| 192 | + name: bindings-linux-musl-${{ matrix.arch }} |
| 193 | + path: packages/*/*/*.node |
| 194 | + - name: debug |
| 195 | + run: ls -l packages/*/*/*.node |
| 196 | + - name: Smoke test |
| 197 | + if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }} |
| 198 | + run: node -e 'require("@parcel/rust")' |
| 199 | + |
| 200 | + build-and-release: |
| 201 | + runs-on: ubuntu-20.04 |
| 202 | + name: Build and release |
| 203 | + needs: |
| 204 | + - build-macos-windows |
| 205 | + - build-linux-musl |
| 206 | + - build-linux-gnu-arm |
| 207 | + steps: |
| 208 | + - uses: actions/checkout@v4 |
| 209 | + with: |
| 210 | + fetch-depth: 0 |
| 211 | + - uses: bahmutov/[email protected] |
| 212 | + - name: Build native packages |
| 213 | + run: yarn build-native-release |
| 214 | + - name: Download artifacts |
| 215 | + uses: actions/download-artifact@v3 |
| 216 | + with: |
| 217 | + path: artifacts |
| 218 | + - name: Move artifacts |
| 219 | + run: for d in artifacts/*/*/*; do cp $d/*.node packages/$(basename $(dirname $d))/$(basename $d); done |
| 220 | + - name: Debug |
| 221 | + run: ls -l packages/*/*/*.node |
| 222 | + - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc |
| 223 | + env: |
| 224 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 225 | + - run: ${{ inputs.release-command }} |
0 commit comments