release.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. # Release workflow
  2. #
  3. # We parallelize builds, dump all the artifacts into a release, and then publish the release
  4. # This guarantees everything is properly built and cached in case anything goes wrong
  5. #
  6. # The artifacts also need to get pushed to the various places
  7. # - the CLI goes to the releases page for binstall
  8. # - the extension goes to the marketplace
  9. # - the docs go to the website
  10. #
  11. # We need to be aware of the channel we're releasing
  12. # - prerelease is master
  13. # - stable is whatever the latest stable release is (ie 0.4 or 0.5 or 0.6 etc)
  14. #
  15. # In theory, we could trigger this workflow and set the channel accordingly
  16. on:
  17. workflow_dispatch:
  18. inputs:
  19. channel:
  20. type: choice
  21. description: "Branch to publish"
  22. required: true
  23. description: Choose the branch to publish. If the branch is main, it will publish a prerelease.
  24. # add more options as we release more stable versions.
  25. # todo: automate branch selection
  26. options:
  27. - v0.4.x
  28. - v0.5.x
  29. - main
  30. jobs:
  31. # Build the CLI for all platforms
  32. build-cli:
  33. permissions:
  34. contents: write
  35. runs-on: ${{ matrix.platform.os }}
  36. strategy:
  37. matrix:
  38. platform:
  39. - {
  40. target: x86_64-pc-windows-msvc,
  41. os: windows-latest,
  42. toolchain: "1.70.0",
  43. }
  44. - {
  45. target: x86_64-apple-darwin,
  46. os: macos-latest,
  47. toolchain: "1.70.0",
  48. }
  49. - {
  50. target: x86_64-unknown-linux-gnu,
  51. os: ubuntu-latest,
  52. toolchain: "1.70.0",
  53. }
  54. steps:
  55. - uses: actions/checkout@v4
  56. ref: ${{ github.event.inputs.channel }}
  57. - name: Install stable
  58. uses: dtolnay/rust-toolchain@master
  59. with:
  60. toolchain: ${{ matrix.platform.toolchain }}
  61. targets: ${{ matrix.platform.target }}
  62. - uses: ilammy/setup-nasm@v1
  63. - name: Setup cache
  64. uses: Swatinem/rust-cache@v2
  65. # cache only the cli - mmmm not sure if this is needed
  66. with:
  67. workspaces: packages/cli -> ../../target
  68. # Build the vscode extension
  69. build-extension:
  70. # Build the docs
  71. build-docs:
  72. # Run benchmarks, which we'll use to display on the website
  73. build-benchmarks:
  74. # And then do the releases, once everything is built
  75. # This should involve no rust and just pull down the artifacts
  76. release:
  77. depends-on: [build-cli, build-extension, build-docs, build-benchmarks]
  78. # Checkout the right branch
  79. - uses: actions/checkout@v4
  80. ref: ${{ github.event.inputs.channel }}
  81. # Before anything else, we need to publish the crates
  82. # todo: set the semver based on the channel
  83. # - all semver is a minor bump,
  84. # - if it's main, it's a prerelease, so use the prerelease flag
  85. - name: Publish to crates.io
  86. run: |
  87. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  88. git config --global user.name "github-actions[bot]"
  89. # cargo workspaces version -y ${{ github.event.inputs.semver }}
  90. # cargo workspaces publish -y ${{ github.event.inputs.semver }}
  91. # Todo: we want `cargo install dx` to actually just use a prebuilt binary
  92. - name: Build and upload CLI binaries
  93. uses: taiki-e/upload-rust-binary-action@v1
  94. with:
  95. token: ${{ secrets.GITHUB_TOKEN }}
  96. target: ${{ matrix.platform.target }}
  97. bin: dx
  98. archive: dx-${{ matrix.platform.target }}
  99. checksum: sha256
  100. manifest_path: packages/cli/Cargo.toml
  101. # build the docs, CLI, extension, and release
  102. jobs:
  103. build-deploy:
  104. runs-on: ubuntu-latest
  105. environment: docs
  106. steps:
  107. # install rust, etc, with caching, and do some checks
  108. - uses: actions/checkout@v4
  109. - run: sudo apt-get update
  110. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  111. - uses: dtolnay/rust-toolchain@stable
  112. - uses: Swatinem/rust-cache@v2
  113. with:
  114. cache-all-crates: "true"
  115. # save-if: ${{ github.ref == 'refs/heads/main' }} # always save the cache
  116. - name: Free Disk Space (Ubuntu)
  117. uses: jlumbroso/free-disk-space@v1.3.1
  118. with: # speed things up a bit
  119. large-packages: false
  120. docker-images: false
  121. swap-storage: false
  122. # Just make sure clippy is happy before doing anything else
  123. # Don't publish versions with clippy errors!
  124. - name: Clippy
  125. run: cargo clippy --workspace --all --examples --tests --all-features --all-targets -- -D warnings
  126. # Build the CLI... todo: do this in a matrix using binstall
  127. - name: Build CLI
  128. run: cargo build --release --bin dx
  129. - name: Build Extension
  130. run: cargo build --release --bin dx-ext
  131. - name: Bundle extension
  132. working-directory: ./packages/extension
  133. run: vsce package && mv *.vsix ../../dx-ext.vsix
  134. # Docs first...
  135. # NOTE: Delete when the previous one is enabled
  136. # NOTE: Comment out when https://github.com/rust-lang/mdBook/pull/1306 is merged and released
  137. # - name: Setup mdBook
  138. # uses: peaceiris/actions-mdbook@v1
  139. # with:
  140. # mdbook-version: "0.4.10"
  141. - name: Setup mdBook
  142. run: |
  143. cargo install mdbook --git https://github.com/Demonthos/mdBook.git --branch master
  144. - name: Build
  145. run: cd docs &&
  146. cd guide && mdbook build -d ../nightly/guide && cd .. &&
  147. cd router && mdbook build -d ../nightly/router && cd ..
  148. - name: Deploy docs 🚀
  149. uses: JamesIves/github-pages-deploy-action@v4.5.0
  150. with:
  151. branch: gh-pages # The branch the action should deploy to.
  152. folder: docs/nightly # The folder the action should deploy.
  153. target-folder: docs
  154. repository-name: dioxuslabs/docsite
  155. # Don't clean the existing files, so the old docs are still available.
  156. # todo: the history on the dociste is getting massive, so we should actually just be amending the commit
  157. clean: false
  158. token: ${{ secrets.DEPLOY_KEY }}
  159. # Then the CLI
  160. # Then the extension
  161. # Then the release itself
  162. # Release a number of things
  163. # - the extension
  164. # - the CLI
  165. # - nightly docs
  166. # - the website
  167. # - crates themselves
  168. # name: Publish to crates.io
  169. # on:
  170. # workflow_dispatch:
  171. # inputs:
  172. # semver:
  173. # type: choice
  174. # description: "Semver version to publish"
  175. # required: true
  176. # options:
  177. # - patch
  178. # - minor
  179. # - major
  180. # jobs:
  181. # publish:
  182. # runs-on: ubuntu-latest
  183. # steps:
  184. # - name: Checkout code
  185. # uses: actions/checkout@v2
  186. # - name: Set up Rust
  187. # uses: actions-rs/toolchain@v1
  188. # with:
  189. # toolchain: nightly
  190. # override: true
  191. # - name: Install cargo-workspaces
  192. # run: cargo install cargo-workspaces
  193. # - name: Login to crates.io
  194. # uses: actions-rs/cargo@v1
  195. # with:
  196. # toolchain: nightly
  197. # command: login
  198. # args: ${{ secrets.CRATES_TOKEN }}
  199. # - name: Publish to crates.io
  200. # run: |
  201. # git config --global user.email "github-actions[bot]@users.noreply.github.com"
  202. # git config --global user.name "github-actions[bot]"
  203. # # Release as-is
  204. # # This assumes the version tracking PR has been merged
  205. # # cargo workspaces changed
  206. # # # version will automatically commit back to the repo
  207. # # # cargo workspaces version -y ${{ github.event.inputs.semver }}
  208. # Whenever commits are merged to main, update or create a PR that bumps the version
  209. # Tracks if changes are semver compatible
  210. #
  211. # We want to have a standing "major" update PR and a standing "minor" update PR where fixes are backported
  212. #
  213. # Whenever a PR is merged, we want to attempt to update the major/minor bump PRs
  214. # - for main, it's as simple as running cargo workspaces version -y minor and dumping it into a PR
  215. # - for backport, it's a bit more complicated, since we need to know which branch is the latest stable release
  216. #
  217. # - We could make it so merging a PR with a "backport" label attempts to release it, using the target branch as the stable release
  218. # on:
  219. # push:
  220. # branches:
  221. # - master
  222. # # Generate the minor bump
  223. # jobs:
  224. # update_routes:
  225. # runs-on: ubuntu-latest
  226. # steps:
  227. # # Check out the repo, but don't persist credentials, so github uses the GITHUB_TOKEN
  228. # - uses: actions/checkout@v2
  229. # with:
  230. # persist-credentials: false
  231. # # Run cargo workspaces version to generate the version bump PR
  232. # - run: "date > datetime.txt" # create or update a test.txt file
  233. # # And then create the PR
  234. # - uses: gr2m/create-or-update-pull-request-action@v1
  235. # env:
  236. # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  237. # with:
  238. # title: "My pull request title"
  239. # body: "My pull request body"
  240. # branch: "my-pull-request-base-branch"
  241. # path: "lib/"
  242. # commit-message: "My commit message for uncommitted changes in lib/ folder"
  243. # author: "Lorem J. Ipsum <lorem@example.com>"
  244. # labels: label1, label2
  245. # assignees: user1, user2
  246. # reviewers: user1, user2
  247. # team_reviewers: team1, team2
  248. # auto-merge: squash
  249. # update-pull-request-title-and-body: false
  250. # # Generate the major bump
  251. # # # # publish will automatically commit back to the repo **AND** publish to crates.io
  252. # # # # cargo workspaces publish -y ${{ github.event.inputs.semver }}
  253. # name: Deploy Nightly Docs
  254. # on:
  255. # push:
  256. # branches:
  257. # - main
  258. # jobs:
  259. # deploy:
  260. # name: Build & Deploy
  261. # runs-on: ubuntu-latest
  262. # permissions:
  263. # contents: write
  264. # steps:
  265. # - uses: actions/checkout@v4
  266. # - run: sudo apt-get update
  267. # - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  268. # - uses: dtolnay/rust-toolchain@nightly
  269. # with:
  270. # toolchain: nightly-2024-02-01
  271. # - uses: Swatinem/rust-cache@v2
  272. # with:
  273. # cache-all-crates: "true"
  274. # save-if: ${{ github.ref == 'refs/heads/main' }}
  275. # - uses: ilammy/setup-nasm@v1
  276. # - name: cargo doc
  277. # run: cargo doc --no-deps --workspace --all-features
  278. # - name: Deploy
  279. # uses: JamesIves/github-pages-deploy-action@v4.5.0
  280. # with:
  281. # branch: gh-pages
  282. # folder: target/doc
  283. # target-folder: api-docs/nightly
  284. # repository-name: dioxuslabs/docsite
  285. # clean: false
  286. # token: ${{ secrets.DEPLOY_KEY }}
  287. # name: docs stable
  288. # on:
  289. # workflow_dispatch:
  290. # concurrency:
  291. # group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  292. # cancel-in-progress: true
  293. # jobs:
  294. # build-deploy:
  295. # runs-on: ubuntu-latest
  296. # environment: docs
  297. # steps:
  298. # # NOTE: Comment out when https://github.com/rust-lang/mdBook/pull/1306 is merged and released
  299. # # - name: Setup mdBook
  300. # # uses: peaceiris/actions-mdbook@v1
  301. # # with:
  302. # # mdbook-version: "0.4.10"
  303. # # NOTE: Delete when the previous one is enabled
  304. # - name: Setup mdBook
  305. # run: |
  306. # cargo install mdbook --git https://github.com/Demonthos/mdBook.git --branch master
  307. # - uses: actions/checkout@v4
  308. # - name: Build
  309. # run: cd docs &&
  310. # cd guide && mdbook build -d ../nightly/guide && cd .. &&
  311. # cd router && mdbook build -d ../nightly/router && cd ..
  312. # - name: Deploy 🚀
  313. # uses: JamesIves/github-pages-deploy-action@v4.5.0
  314. # with:
  315. # branch: gh-pages # The branch the action should deploy to.
  316. # folder: docs/nightly # The folder the action should deploy.
  317. # target-folder: docs
  318. # repository-name: dioxuslabs/docsite
  319. # clean: false
  320. # token: ${{ secrets.DEPLOY_KEY }} # let's pretend I don't need it for now
  321. # name: Build CLI for Release
  322. # # Will run automatically on every new release
  323. # on:
  324. # release:
  325. # types: [published]
  326. # jobs:
  327. # build-and-upload:
  328. # permissions:
  329. # contents: write
  330. # runs-on: ${{ matrix.platform.os }}
  331. # strategy:
  332. # matrix:
  333. # platform:
  334. # - {
  335. # target: x86_64-pc-windows-msvc,
  336. # os: windows-latest,
  337. # toolchain: "1.70.0",
  338. # }
  339. # - {
  340. # target: x86_64-apple-darwin,
  341. # os: macos-latest,
  342. # toolchain: "1.70.0",
  343. # }
  344. # - {
  345. # target: x86_64-unknown-linux-gnu,
  346. # os: ubuntu-latest,
  347. # toolchain: "1.70.0",
  348. # }
  349. # steps:
  350. # - uses: actions/checkout@v4
  351. # - name: Install stable
  352. # uses: dtolnay/rust-toolchain@master
  353. # with:
  354. # toolchain: ${{ matrix.platform.toolchain }}
  355. # targets: ${{ matrix.platform.target }}
  356. # - uses: ilammy/setup-nasm@v1
  357. # # Setup the Github Actions Cache for the CLI package
  358. # - name: Setup cache
  359. # uses: Swatinem/rust-cache@v2
  360. # with:
  361. # workspaces: packages/cli -> ../../target
  362. # # This neat action can build and upload the binary in one go!
  363. # - name: Build and upload binary
  364. # uses: taiki-e/upload-rust-binary-action@v1
  365. # with:
  366. # token: ${{ secrets.GITHUB_TOKEN }}
  367. # target: ${{ matrix.platform.target }}
  368. # bin: dx
  369. # archive: dx-${{ matrix.platform.target }}
  370. # checksum: sha256
  371. # manifest_path: packages/cli/Cargo.toml