release.yml 14 KB

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