|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_channel: |
| 7 | + description: 'Release channel' |
| 8 | + required: false |
| 9 | + default: 'internal' |
| 10 | + type: string |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +env: |
| 16 | + APP_NAME: tailwindcss-oxide |
| 17 | + NODE_VERSION: 20 |
| 18 | + PNPM_VERSION: ^8.15.0 |
| 19 | + OXIDE_LOCATION: ./oxide/crates/node |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + # Windows |
| 27 | + - os: windows-latest |
| 28 | + target: x86_64-pc-windows-msvc |
| 29 | + # macOS |
| 30 | + - os: macos-latest |
| 31 | + target: x86_64-apple-darwin |
| 32 | + strip: strip -x # Must use -x on macOS. This produces larger results on linux. |
| 33 | + - os: macos-latest |
| 34 | + target: aarch64-apple-darwin |
| 35 | + page-size: 14 |
| 36 | + strip: strip -x # Must use -x on macOS. This produces larger results on linux. |
| 37 | + # Linux |
| 38 | + - os: ubuntu-latest |
| 39 | + target: x86_64-unknown-linux-gnu |
| 40 | + strip: strip |
| 41 | + container: |
| 42 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian |
| 43 | + - os: ubuntu-latest |
| 44 | + target: aarch64-unknown-linux-gnu |
| 45 | + strip: llvm-strip |
| 46 | + container: |
| 47 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 |
| 48 | + - os: ubuntu-latest |
| 49 | + target: armv7-unknown-linux-gnueabihf |
| 50 | + strip: llvm-strip |
| 51 | + container: |
| 52 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-zig |
| 53 | + - os: ubuntu-latest |
| 54 | + target: aarch64-unknown-linux-musl |
| 55 | + strip: aarch64-linux-musl-strip |
| 56 | + download: true |
| 57 | + container: |
| 58 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 59 | + - os: ubuntu-latest |
| 60 | + target: x86_64-unknown-linux-musl |
| 61 | + strip: strip |
| 62 | + download: true |
| 63 | + container: |
| 64 | + image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine |
| 65 | + |
| 66 | + name: Build ${{ matrix.target }} (OXIDE) |
| 67 | + runs-on: ${{ matrix.os }} |
| 68 | + container: ${{ matrix.container }} |
| 69 | + timeout-minutes: 15 |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v3 |
| 72 | + - uses: pnpm/action-setup@v3 |
| 73 | + with: |
| 74 | + version: ${{ env.PNPM_VERSION }} |
| 75 | + |
| 76 | + - name: Use Node.js ${{ env.NODE_VERSION }} |
| 77 | + uses: actions/setup-node@v3 |
| 78 | + with: |
| 79 | + node-version: ${{ env.NODE_VERSION }} |
| 80 | + cache: 'pnpm' |
| 81 | + |
| 82 | + # Cargo already skips downloading dependencies if they already exist |
| 83 | + - name: Cache cargo |
| 84 | + uses: actions/cache@v3 |
| 85 | + with: |
| 86 | + path: | |
| 87 | + ~/.cargo/bin/ |
| 88 | + ~/.cargo/registry/index/ |
| 89 | + ~/.cargo/registry/cache/ |
| 90 | + ~/.cargo/git/db/ |
| 91 | + target/ |
| 92 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 93 | + |
| 94 | + # Cache the `oxide` Rust build |
| 95 | + - name: Cache oxide build |
| 96 | + uses: actions/cache@v3 |
| 97 | + with: |
| 98 | + path: | |
| 99 | + ./oxide/target/ |
| 100 | + ./oxide/crates/node/*.node |
| 101 | + ./oxide/crates/node/index.js |
| 102 | + ./oxide/crates/node/index.d.ts |
| 103 | + key: ${{ runner.os }}-${{ matrix.target }}-oxide-${{ hashFiles('./oxide/crates/**/*') }} |
| 104 | + |
| 105 | + - name: Install Node.JS |
| 106 | + uses: actions/setup-node@v3 |
| 107 | + with: |
| 108 | + node-version: ${{ env.NODE_VERSION }} |
| 109 | + |
| 110 | + - name: Setup cross compile toolchain |
| 111 | + if: ${{ matrix.setup }} |
| 112 | + run: ${{ matrix.setup }} |
| 113 | + |
| 114 | + - name: Install Rust (Stable) |
| 115 | + if: ${{ matrix.download }} |
| 116 | + run: | |
| 117 | + rustup default stable |
| 118 | +
|
| 119 | + - name: Setup rust target |
| 120 | + run: rustup target add ${{ matrix.target }} |
| 121 | + |
| 122 | + - name: Install dependencies |
| 123 | + run: pnpm install --ignore-scripts --filter=!./playgrounds/* |
| 124 | + |
| 125 | + - name: Build release |
| 126 | + run: pnpm run build --filter ${{ env.OXIDE_LOCATION }} |
| 127 | + env: |
| 128 | + RUST_TARGET: ${{ matrix.target }} |
| 129 | + JEMALLOC_SYS_WITH_LG_PAGE: ${{ matrix.page-size }} |
| 130 | + |
| 131 | + - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034 |
| 132 | + if: ${{ matrix.strip }} |
| 133 | + run: ${{ matrix.strip }} ${{ env.OXIDE_LOCATION }}/*.node |
| 134 | + |
| 135 | + - name: Upload artifacts |
| 136 | + uses: actions/upload-artifact@v3 |
| 137 | + with: |
| 138 | + name: bindings-${{ matrix.target }} |
| 139 | + path: ${{ env.OXIDE_LOCATION }}/*.node |
| 140 | + |
| 141 | + release: |
| 142 | + runs-on: ubuntu-latest |
| 143 | + timeout-minutes: 15 |
| 144 | + name: Build and release Tailwind CSS |
| 145 | + |
| 146 | + needs: |
| 147 | + - build |
| 148 | + |
| 149 | + steps: |
| 150 | + - uses: actions/checkout@v3 |
| 151 | + - uses: pnpm/action-setup@v3 |
| 152 | + with: |
| 153 | + version: ${{ env.PNPM_VERSION }} |
| 154 | + |
| 155 | + - name: Use Node.js ${{ env.NODE_VERSION }} |
| 156 | + uses: actions/setup-node@v3 |
| 157 | + with: |
| 158 | + node-version: ${{ env.NODE_VERSION }} |
| 159 | + cache: 'pnpm' |
| 160 | + registry-url: 'https://registry.npmjs.org' |
| 161 | + |
| 162 | + # Cargo already skips downloading dependencies if they already exist |
| 163 | + - name: Cache cargo |
| 164 | + uses: actions/cache@v3 |
| 165 | + with: |
| 166 | + path: | |
| 167 | + ~/.cargo/bin/ |
| 168 | + ~/.cargo/registry/index/ |
| 169 | + ~/.cargo/registry/cache/ |
| 170 | + ~/.cargo/git/db/ |
| 171 | + target/ |
| 172 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 173 | + |
| 174 | + # Cache the `oxide` Rust build |
| 175 | + - name: Cache oxide build |
| 176 | + uses: actions/cache@v3 |
| 177 | + with: |
| 178 | + path: | |
| 179 | + ./oxide/target/ |
| 180 | + ./oxide/crates/node/*.node |
| 181 | + ./oxide/crates/node/index.js |
| 182 | + ./oxide/crates/node/index.d.ts |
| 183 | + key: ${{ runner.os }}-${{ matrix.target }}-oxide-${{ hashFiles('./oxide/crates/**/*') }} |
| 184 | + |
| 185 | + - name: Install dependencies |
| 186 | + run: pnpm install --ignore-scripts --filter=!./playgrounds/* |
| 187 | + |
| 188 | + - name: Build Tailwind CSS |
| 189 | + run: pnpm run build |
| 190 | + |
| 191 | + - name: Download artifacts |
| 192 | + uses: actions/download-artifact@v3 |
| 193 | + with: |
| 194 | + path: ${{ env.OXIDE_LOCATION }} |
| 195 | + |
| 196 | + - name: Move artifacts |
| 197 | + run: | |
| 198 | + cd ${{ env.OXIDE_LOCATION }} |
| 199 | + cp bindings-x86_64-pc-windows-msvc/* ./npm/win32-x64-msvc/ |
| 200 | + cp bindings-x86_64-apple-darwin/* ./npm/darwin-x64/ |
| 201 | + cp bindings-aarch64-apple-darwin/* ./npm/darwin-arm64/ |
| 202 | + cp bindings-aarch64-unknown-linux-gnu/* ./npm/linux-arm64-gnu/ |
| 203 | + cp bindings-aarch64-unknown-linux-musl/* ./npm/linux-arm64-musl/ |
| 204 | + cp bindings-armv7-unknown-linux-gnueabihf/* ./npm/linux-arm-gnueabihf/ |
| 205 | + cp bindings-x86_64-unknown-linux-gnu/* ./npm/linux-x64-gnu/ |
| 206 | + cp bindings-x86_64-unknown-linux-musl/* ./npm/linux-x64-musl/ |
| 207 | +
|
| 208 | + - name: Lock pre-release versions |
| 209 | + run: node ./scripts/lock-pre-release-versions.mjs |
| 210 | + |
| 211 | + - name: Publish |
| 212 | + run: pnpm --recursive publish --tag ${{ inputs.release_channel }} --no-git-checks |
| 213 | + env: |
| 214 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments