release.yml 7.4 KB

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