|
| 1 | +name: Release npm cli |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + strategy: |
| 8 | + fail-fast: false |
| 9 | + matrix: |
| 10 | + include: |
| 11 | + # Windows |
| 12 | + - os: windows-latest |
| 13 | + target: x86_64-pc-windows-msvc |
| 14 | + binary: parcel_css.exe |
| 15 | + # Mac OS |
| 16 | + - os: macos-latest |
| 17 | + target: x86_64-apple-darwin |
| 18 | + strip: strip -x # Must use -x on macOS. This produces larger results on linux. |
| 19 | + binary: parcel_css |
| 20 | + |
| 21 | + name: build-${{ matrix.target }} |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v2 |
| 25 | + - name: Install Node.JS |
| 26 | + uses: actions/setup-node@v2 |
| 27 | + with: |
| 28 | + node-version: 14 |
| 29 | + - name: Install Rust |
| 30 | + uses: actions-rs/toolchain@v1 |
| 31 | + with: |
| 32 | + toolchain: stable |
| 33 | + profile: minimal |
| 34 | + override: true |
| 35 | + |
| 36 | + - name: Setup rust target |
| 37 | + run: rustup target add ${{ matrix.target }} |
| 38 | + |
| 39 | + - uses: bahmutov/[email protected] |
| 40 | + - name: Build release |
| 41 | + run: yarn build-release |
| 42 | + env: |
| 43 | + RUST_TARGET: ${{ matrix.target }} |
| 44 | + - name: Build CLI |
| 45 | + run: | |
| 46 | + cargo build --release --features cli --target ${{ matrix.target }} |
| 47 | + node -e "require('fs').renameSync('target/${{ matrix.target }}/release/${{ matrix.binary }}', '${{ matrix.binary }}')" |
| 48 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 49 | + if: ${{ matrix.strip }} |
| 50 | + run: ${{ matrix.strip }} *.node ${{ matrix.binary }} |
| 51 | + - name: Upload artifacts |
| 52 | + uses: actions/upload-artifact@v2 |
| 53 | + with: |
| 54 | + name: bindings-${{ matrix.target }} |
| 55 | + path: | |
| 56 | + *.node |
| 57 | + ${{ matrix.binary }} |
| 58 | + build-apple-silicon: |
| 59 | + name: build-apple-silicon |
| 60 | + runs-on: macos-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v2 |
| 63 | + - name: Install Node.JS |
| 64 | + uses: actions/setup-node@v2 |
| 65 | + with: |
| 66 | + node-version: 14 |
| 67 | + - name: Install Rust |
| 68 | + uses: actions-rs/toolchain@v1 |
| 69 | + with: |
| 70 | + toolchain: stable |
| 71 | + profile: minimal |
| 72 | + override: true |
| 73 | + |
| 74 | + - name: Setup rust target |
| 75 | + run: rustup target add aarch64-apple-darwin |
| 76 | + |
| 77 | + - uses: bahmutov/[email protected] |
| 78 | + - name: Build release |
| 79 | + run: yarn build-release |
| 80 | + env: |
| 81 | + RUST_TARGET: aarch64-apple-darwin |
| 82 | + JEMALLOC_SYS_WITH_LG_PAGE: 14 |
| 83 | + - name: Build CLI |
| 84 | + run: | |
| 85 | + export CC=$(xcrun -f clang); |
| 86 | + export CXX=$(xcrun -f clang++); |
| 87 | + SYSROOT=$(xcrun --sdk macosx --show-sdk-path); |
| 88 | + export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; |
| 89 | + export MACOSX_DEPLOYMENT_TARGET="10.9"; |
| 90 | + cargo build --release --features cli --target aarch64-apple-darwin |
| 91 | + mv target/aarch64-apple-darwin/release/parcel_css parcel_css |
| 92 | + env: |
| 93 | + JEMALLOC_SYS_WITH_LG_PAGE: 14 |
| 94 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 95 | + run: strip -x *.node parcel_css |
| 96 | + - name: Upload artifacts |
| 97 | + uses: actions/upload-artifact@v2 |
| 98 | + with: |
| 99 | + name: bindings-aarch64-apple-darwin |
| 100 | + path: | |
| 101 | + *.node |
| 102 | + parcel_css |
| 103 | + build-linux: |
| 104 | + strategy: |
| 105 | + fail-fast: false |
| 106 | + matrix: |
| 107 | + include: |
| 108 | + - target: x86_64-unknown-linux-gnu |
| 109 | + strip: strip |
| 110 | + image: docker.io/centos/nodejs-12-centos7 |
| 111 | + setup: npm install --global yarn@1 |
| 112 | + - target: aarch64-unknown-linux-gnu |
| 113 | + strip: aarch64-linux-gnu-strip |
| 114 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 115 | + setup: apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y |
| 116 | + - target: armv7-unknown-linux-gnueabihf |
| 117 | + strip: arm-linux-gnueabihf-strip |
| 118 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 119 | + setup: apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y |
| 120 | + - target: aarch64-unknown-linux-musl |
| 121 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 122 | + strip: aarch64-linux-musl-strip |
| 123 | + - target: x86_64-unknown-linux-musl |
| 124 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 125 | + strip: strip |
| 126 | + |
| 127 | + name: build-${{ matrix.target }} |
| 128 | + runs-on: ubuntu-latest |
| 129 | + container: |
| 130 | + image: ${{ matrix.image }} |
| 131 | + |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@v2 |
| 134 | + - name: Install Node.JS |
| 135 | + uses: actions/setup-node@v2 |
| 136 | + with: |
| 137 | + node-version: 14 |
| 138 | + - name: Install Rust |
| 139 | + uses: actions-rs/toolchain@v1 |
| 140 | + with: |
| 141 | + toolchain: stable |
| 142 | + profile: minimal |
| 143 | + override: true |
| 144 | + |
| 145 | + - name: Setup cross compile toolchain |
| 146 | + if: ${{ matrix.setup }} |
| 147 | + run: ${{ matrix.setup }} |
| 148 | + |
| 149 | + - name: Setup rust target |
| 150 | + run: rustup target add ${{ matrix.target }} |
| 151 | + |
| 152 | + - uses: bahmutov/[email protected] |
| 153 | + - name: Build release |
| 154 | + run: yarn build-release |
| 155 | + env: |
| 156 | + RUST_TARGET: ${{ matrix.target }} |
| 157 | + - name: Build CLI |
| 158 | + run: | |
| 159 | + cargo build --release --features cli --target ${{ matrix.target }} |
| 160 | + mv target/${{ matrix.target }}/release/parcel_css parcel_css |
| 161 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 162 | + if: ${{ matrix.strip }} |
| 163 | + run: ${{ matrix.strip }} *.node parcel_css |
| 164 | + - name: Upload artifacts |
| 165 | + uses: actions/upload-artifact@v2 |
| 166 | + with: |
| 167 | + name: bindings-${{ matrix.target }} |
| 168 | + path: | |
| 169 | + *.node |
| 170 | + parcel_css |
| 171 | + build-wasm: |
| 172 | + runs-on: ubuntu-latest |
| 173 | + steps: |
| 174 | + - uses: actions/checkout@v2 |
| 175 | + - name: Install Node.JS |
| 176 | + uses: actions/setup-node@v2 |
| 177 | + with: |
| 178 | + node-version: 14 |
| 179 | + - name: Install wasm-pack |
| 180 | + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh |
| 181 | + - name: Build wasm |
| 182 | + run: yarn wasm-browser:build-release |
| 183 | + - name: Upload artifacts |
| 184 | + uses: actions/upload-artifact@v2 |
| 185 | + with: |
| 186 | + name: wasm |
| 187 | + path: node/pkg |
| 188 | + |
| 189 | + release: |
| 190 | + runs-on: ubuntu-latest |
| 191 | + name: Build and release |
| 192 | + needs: |
| 193 | + - build |
| 194 | + - build-linux |
| 195 | + - build-apple-silicon |
| 196 | + - build-wasm |
| 197 | + steps: |
| 198 | + - uses: actions/checkout@v1 |
| 199 | + - uses: bahmutov/[email protected] |
| 200 | + - name: Download artifacts |
| 201 | + uses: actions/download-artifact@v2 |
| 202 | + with: |
| 203 | + path: artifacts |
| 204 | + - name: Build npm packages |
| 205 | + run: | |
| 206 | + node scripts/build-npm.js |
| 207 | + node scripts/build-wasm.js |
| 208 | + - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc |
| 209 | + env: |
| 210 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 211 | + - name: Publish to npm |
| 212 | + run: | |
| 213 | + for pkg in npm/*; do |
| 214 | + echo "Publishing $pkg..." |
| 215 | + cd $pkg; |
| 216 | + npm publish; |
| 217 | + cd ../..; |
| 218 | + done |
| 219 | + cd cli |
| 220 | + echo "Publishing @parcel/css-cli..."; |
| 221 | + npm publish |
| 222 | + cd .. |
| 223 | + echo "Publishing @parcel/css..."; |
| 224 | + npm publish |
| 225 | + release-crates: |
| 226 | + runs-on: ubuntu-latest |
| 227 | + name: Release Rust crate |
| 228 | + steps: |
| 229 | + - uses: actions/checkout@v1 |
| 230 | + - uses: bahmutov/[email protected] |
| 231 | + - name: Install Rust |
| 232 | + uses: actions-rs/toolchain@v1 |
| 233 | + with: |
| 234 | + toolchain: stable |
| 235 | + profile: minimal |
| 236 | + override: true |
| 237 | + - run: cargo login ${CRATES_IO_TOKEN} |
| 238 | + env: |
| 239 | + CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} |
| 240 | + - run: | |
| 241 | + cargo install cargo-workspaces |
| 242 | + cargo workspaces publish --from-git -y |
0 commit comments