release-insiders.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. name: Release Insiders
  2. on:
  3. push:
  4. branches: [master]
  5. env:
  6. APP_NAME: tailwindcss-oxide
  7. NODE_VERSION: 16
  8. OXIDE_LOCATION: ./oxide/crates/node
  9. RELEASE_CHANNEL: insiders
  10. jobs:
  11. build:
  12. strategy:
  13. fail-fast: false
  14. matrix:
  15. include:
  16. # Windows
  17. - os: windows-latest
  18. target: x86_64-pc-windows-msvc
  19. # Mac OS
  20. - os: macos-latest
  21. target: x86_64-apple-darwin
  22. strip: strip -x # Must use -x on macOS. This produces larger results on linux.
  23. name: Build ${{ matrix.target }} (OXIDE)
  24. runs-on: ${{ matrix.os }}
  25. timeout-minutes: 15
  26. steps:
  27. - uses: actions/checkout@v3
  28. - name: Cache node_modules
  29. uses: actions/cache@v3
  30. with:
  31. path: node_modules
  32. key: ${{ runner.os }}-${{ matrix.target }}-${{ env.NODE_VERSION }}-node_modules-${{ hashFiles('**/package-lock.json') }}
  33. # Cargo already skips downloading dependencies if they already exist
  34. - name: Cache cargo
  35. uses: actions/cache@v3
  36. with:
  37. path: |
  38. ~/.cargo/bin/
  39. ~/.cargo/registry/index/
  40. ~/.cargo/registry/cache/
  41. ~/.cargo/git/db/
  42. target/
  43. key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  44. # Cache the `oxide` Rust build
  45. - name: Cache oxide build
  46. uses: actions/cache@v3
  47. with:
  48. path: |
  49. ./oxide/target/
  50. ./oxide/crates/node/*.node
  51. ./oxide/crates/node/index.js
  52. ./oxide/crates/node/index.d.ts
  53. key: ${{ runner.os }}-${{ matrix.target }}-oxide-${{ hashFiles('./oxide/crates/**/*') }}
  54. - name: Install Node.JS
  55. uses: actions/setup-node@v3
  56. with:
  57. node-version: ${{ env.NODE_VERSION }}
  58. - name: Setup rust target
  59. run: rustup target add ${{ matrix.target }}
  60. - name: Install dependencies
  61. run: npm install
  62. - name: Build release
  63. run: cd ${{ env.OXIDE_LOCATION }} && npm run build
  64. env:
  65. RUST_TARGET: ${{ matrix.target }}
  66. - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
  67. if: ${{ matrix.strip }}
  68. run: ${{ matrix.strip }} ${{ env.OXIDE_LOCATION }}/*.node
  69. - name: Upload artifacts
  70. uses: actions/upload-artifact@v3
  71. with:
  72. name: bindings-${{ matrix.target }}
  73. path: |
  74. ${{ env.OXIDE_LOCATION }}/*.node
  75. ${{ matrix.binary }}
  76. build-apple-silicon:
  77. name: Build Apple Silicon (OXIDE)
  78. runs-on: macos-latest
  79. timeout-minutes: 15
  80. steps:
  81. - uses: actions/checkout@v3
  82. - name: Cache node_modules
  83. uses: actions/cache@v3
  84. with:
  85. path: node_modules
  86. key: ${{ runner.os }}-${{ env.NODE_VERSION }}-node_modules-${{ hashFiles('**/package-lock.json') }}
  87. # Cargo already skips downloading dependencies if they already exist
  88. - name: Cache cargo
  89. uses: actions/cache@v3
  90. with:
  91. path: |
  92. ~/.cargo/bin/
  93. ~/.cargo/registry/index/
  94. ~/.cargo/registry/cache/
  95. ~/.cargo/git/db/
  96. target/
  97. key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  98. # Cache the `oxide` Rust build
  99. - name: Cache oxide build
  100. uses: actions/cache@v3
  101. with:
  102. path: |
  103. ./oxide/target/
  104. ./oxide/crates/node/*.node
  105. ./oxide/crates/node/index.js
  106. ./oxide/crates/node/index.d.ts
  107. key: ${{ runner.os }}-oxide-${{ hashFiles('./oxide/crates/**/*') }}
  108. - name: Install Node.JS
  109. uses: actions/setup-node@v3
  110. with:
  111. node-version: ${{ env.NODE_VERSION }}
  112. - name: Setup rust target
  113. run: rustup target add aarch64-apple-darwin
  114. - name: Install dependencies
  115. run: npm install
  116. - name: Build release
  117. run: cd ${{ env.OXIDE_LOCATION }} && npm run build
  118. env:
  119. RUST_TARGET: aarch64-apple-darwin
  120. JEMALLOC_SYS_WITH_LG_PAGE: 14
  121. - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
  122. run: strip -x ${{ env.OXIDE_LOCATION }}/*.node
  123. - name: Upload artifacts
  124. uses: actions/upload-artifact@v3
  125. with:
  126. name: bindings-aarch64-apple-darwin
  127. path: |
  128. ${{ env.OXIDE_LOCATION }}/*.node
  129. ${{ env.APP_NAME }}
  130. build-linux:
  131. strategy:
  132. fail-fast: false
  133. matrix:
  134. include:
  135. - target: x86_64-unknown-linux-gnu
  136. strip: strip
  137. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
  138. download: false
  139. - target: aarch64-unknown-linux-gnu
  140. strip: llvm-strip
  141. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
  142. download: false
  143. - target: armv7-unknown-linux-gnueabihf
  144. strip: llvm-strip
  145. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-zig
  146. download: false
  147. - target: aarch64-unknown-linux-musl
  148. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  149. strip: aarch64-linux-musl-strip
  150. download: true
  151. - target: x86_64-unknown-linux-musl
  152. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  153. strip: strip
  154. download: true
  155. name: Build ${{ matrix.target }} (OXIDE)
  156. runs-on: ubuntu-latest
  157. timeout-minutes: 15
  158. container:
  159. image: ${{ matrix.image }}
  160. steps:
  161. - uses: actions/checkout@v3
  162. - name: Cache node_modules
  163. uses: actions/cache@v3
  164. with:
  165. path: node_modules
  166. key: ${{ runner.os }}-${{ matrix.target }}-${{ env.NODE_VERSION }}-node_modules-${{ hashFiles('**/package-lock.json') }}
  167. # Cargo already skips downloading dependencies if they already exist
  168. - name: Cache cargo
  169. uses: actions/cache@v3
  170. with:
  171. path: |
  172. ~/.cargo/bin/
  173. ~/.cargo/registry/index/
  174. ~/.cargo/registry/cache/
  175. ~/.cargo/git/db/
  176. target/
  177. key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  178. # Cache the `oxide` Rust build
  179. - name: Cache oxide build
  180. uses: actions/cache@v3
  181. with:
  182. path: |
  183. ./oxide/target/
  184. ./oxide/crates/node/*.node
  185. ./oxide/crates/node/index.js
  186. ./oxide/crates/node/index.d.ts
  187. key: ${{ runner.os }}-${{ matrix.target }}-oxide-${{ hashFiles('./oxide/crates/**/*') }}
  188. - name: Install Node.JS
  189. uses: actions/setup-node@v3
  190. with:
  191. node-version: ${{ env.NODE_VERSION }}
  192. - name: Install Rust (Stable)
  193. if: ${{ matrix.download }}
  194. run: |
  195. rustup default stable
  196. - name: Setup rust target
  197. run: rustup target add ${{ matrix.target }}
  198. - name: Install dependencies
  199. run: npm install
  200. - name: Build release
  201. run: cd ${{ env.OXIDE_LOCATION }} && npm run build
  202. env:
  203. RUST_TARGET: ${{ matrix.target }}
  204. - name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
  205. if: ${{ matrix.strip }}
  206. run: ${{ matrix.strip }} ${{ env.OXIDE_LOCATION }}/*.node
  207. - name: Upload artifacts
  208. uses: actions/upload-artifact@v3
  209. with:
  210. name: bindings-${{ matrix.target }}
  211. path: |
  212. ${{ env.OXIDE_LOCATION }}/*.node
  213. ${{ env.APP_NAME }}
  214. release:
  215. runs-on: ubuntu-latest
  216. timeout-minutes: 15
  217. name: Build and release
  218. needs:
  219. - build
  220. - build-linux
  221. - build-apple-silicon
  222. steps:
  223. - uses: actions/checkout@v3
  224. - name: Cache node_modules
  225. uses: actions/cache@v3
  226. with:
  227. path: node_modules
  228. key: ${{ runner.os }}-${{ env.NODE_VERSION }}-node_modules-${{ hashFiles('**/package-lock.json') }}
  229. # Cargo already skips downloading dependencies if they already exist
  230. - name: Cache cargo
  231. uses: actions/cache@v3
  232. with:
  233. path: |
  234. ~/.cargo/bin/
  235. ~/.cargo/registry/index/
  236. ~/.cargo/registry/cache/
  237. ~/.cargo/git/db/
  238. target/
  239. key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
  240. # Cache the `oxide` Rust build
  241. - name: Cache oxide build
  242. uses: actions/cache@v3
  243. with:
  244. path: |
  245. ./oxide/target/
  246. ./oxide/crates/node/*.node
  247. ./oxide/crates/node/index.js
  248. ./oxide/crates/node/index.d.ts
  249. key: ${{ runner.os }}-oxide-${{ hashFiles('./oxide/crates/**/*') }}
  250. - name: Install dependencies
  251. run: npm install
  252. - name: Download artifacts
  253. uses: actions/download-artifact@v3
  254. with:
  255. path: ${{ env.OXIDE_LOCATION }}
  256. - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc
  257. env:
  258. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  259. - name: Move artifacts
  260. run: |
  261. cd ${{ env.OXIDE_LOCATION }}
  262. cp bindings-aarch64-apple-darwin/oxide/crates/node/* ./npm/darwin-arm64/
  263. cp bindings-aarch64-unknown-linux-gnu/oxide/crates/node/* ./npm/linux-arm64-gnu/
  264. cp bindings-aarch64-unknown-linux-musl/oxide/crates/node/* ./npm/linux-arm64-musl/
  265. cp bindings-armv7-unknown-linux-gnueabihf/oxide/crates/node/* ./npm/linux-arm-gnueabihf/
  266. cp bindings-x86_64-apple-darwin/* ./npm/darwin-x64/
  267. cp bindings-x86_64-pc-windows-msvc/* ./npm/win32-x64-msvc/
  268. cp bindings-x86_64-unknown-linux-gnu/oxide/crates/node/* ./npm/linux-x64-gnu/
  269. cp bindings-x86_64-unknown-linux-musl/oxide/crates/node/* ./npm/linux-x64-musl/
  270. - name: Resolve version
  271. id: vars
  272. run: |
  273. echo "NPM_VERSION=0.0.0-${{ env.RELEASE_CHANNEL }}.$(git rev-parse --short HEAD)" >> $GITHUB_ENV
  274. - name: Generate entry point
  275. run: npm run build --prefix ${{ env.OXIDE_LOCATION }}
  276. - name: Publish to npm
  277. run: |
  278. for pkg in ${{ env.OXIDE_LOCATION }}/npm/*; do
  279. echo "Publishing $pkg..."
  280. cd $pkg
  281. npm version ${{ env.NPM_VERSION }} --force --no-git-tag-version
  282. npm publish --tag ${{ env.RELEASE_CHANNEL }} --access public
  283. cd -
  284. done
  285. echo "Publishing ${{ env.APP_NAME }}...";
  286. cd ${{ env.OXIDE_LOCATION }}
  287. npm version ${{ env.NPM_VERSION }} --force --no-git-tag-version
  288. sed "s#\"0.0.0\"#\"${{ env.NPM_VERSION }}\"#g" package.json > package_updated.json
  289. mv package_updated.json package.json
  290. npm publish --tag ${{ env.RELEASE_CHANNEL }} --access public
  291. cd -
  292. env:
  293. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  294. tailwind-release:
  295. runs-on: ubuntu-latest
  296. timeout-minutes: 15
  297. name: Build and release Tailwind CSS
  298. needs:
  299. - release
  300. steps:
  301. - uses: actions/checkout@v3
  302. - name: Use Node.js ${{ env.NODE_VERSION }}
  303. uses: actions/setup-node@v3
  304. with:
  305. node-version: ${{ env.NODE_VERSION }}
  306. registry-url: 'https://registry.npmjs.org'
  307. - name: Resolve version
  308. id: vars
  309. run: |
  310. echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
  311. echo "OXIDE_NPM_VERSION=0.0.0-${{ env.RELEASE_CHANNEL }}.$(git rev-parse --short HEAD)" >> $GITHUB_ENV
  312. - name: Setup `@tailwindcss/oxide` version
  313. run: |
  314. sed "s#\"@tailwindcss/oxide\": \".*\"#\"@tailwindcss/oxide\": \"${{ env.OXIDE_NPM_VERSION }}\"#" package.json > package_updated.json
  315. mv package_updated.json package.json
  316. - name: Install dependencies
  317. run: npm install
  318. - name: Build Tailwind CSS
  319. run: npm run build
  320. - name: Test
  321. run: |
  322. npm test || \
  323. npm test || \
  324. npm test || exit 1
  325. - name: 'Version based on commit: 0.0.0-${{ env.RELEASE_CHANNEL }}.${{ env.SHA_SHORT }}'
  326. run: npm version 0.0.0-${{ env.RELEASE_CHANNEL }}.${{ env.SHA_SHORT }} --force --no-git-tag-version
  327. - name: Publish
  328. run: npm publish --tag ${{ env.RELEASE_CHANNEL }}
  329. env:
  330. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
  331. # !! Enable this, once we are cleaning up all the `stable` engine related files.
  332. #
  333. # - name: Trigger Tailwind Play update
  334. # uses: actions/github-script@v6
  335. # with:
  336. # github-token: ${{ secrets.TAILWIND_PLAY_TOKEN }}
  337. # script: |
  338. # await github.rest.actions.createWorkflowDispatch({
  339. # owner: 'tailwindlabs',
  340. # repo: 'play.tailwindcss.com',
  341. # ref: 'master',
  342. # workflow_id: 'upgrade-tailwindcss.yml',
  343. # inputs: {
  344. # insidersVersion: '0.0.0-${{ env.RELEASE_CHANNEL }}.${{ env.SHA_SHORT }}'
  345. # }
  346. # })