publish.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. # It's intended that this workflow is run manually, and only when we're ready to release
  16. name: Publish
  17. on:
  18. workflow_dispatch:
  19. inputs:
  20. channel:
  21. type: choice
  22. name: "Branch to publish"
  23. required: true
  24. description: Choose the branch to publish.
  25. options:
  26. - main
  27. - v0.4
  28. - v0.5
  29. - v0.6
  30. env:
  31. # make sure we have the right version
  32. # main is always a prepatch until we hit 1.0, and then this script needs to be updated
  33. # note that we need to promote the prepatch to a minor bump when we actually do a release
  34. # this means the version in git will always be one minor bump ahead of the actual release - basically meaning once
  35. # we release a version, it's fair game to merge breaking changes to main since all semver-compatible changes will be
  36. # backported automatically
  37. SEMVER: ${{ github.event.inputs.channel == 'main' && 'prerelease' || 'patch' }}
  38. PRERELEASE_TAG: ${{ github.event.inputs.channel == 'main' && '-pre' || '' }}
  39. jobs:
  40. # First, run checks (clippy, tests, etc) and then publish the crates to crates.io
  41. release-crates:
  42. steps:
  43. # Checkout the right branch, and the nightly stuff
  44. - uses: actions/checkout@v4
  45. ref: ${{ github.event.inputs.channel }}
  46. - run: sudo apt-get update
  47. - run: sudo apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
  48. - uses: dtolnay/rust-toolchain@nightly
  49. with:
  50. toolchain: nightly-2024-02-01
  51. - uses: Swatinem/rust-cache@v2
  52. with:
  53. cache-all-crates: "true"
  54. - name: Free Disk Space (Ubuntu)
  55. uses: jlumbroso/free-disk-space@v1.3.1
  56. with: # speed things up a bit
  57. large-packages: false
  58. docker-images: false
  59. swap-storage: false
  60. # Just make sure clippy is happy before doing anything else
  61. # Don't publish versions with clippy errors!
  62. - name: Clippy
  63. run: cargo clippy --workspace --all --examples --tests --all-features --all-targets -- -D warnings
  64. # Build the docs here too before publishing, to ensure they're up to date
  65. - name: cargo doc
  66. run: RUSTDOCFLAGS="--cfg docsrs" cargo doc --no-deps --workspace --all-features
  67. - name: Publish to crates.io
  68. run: |
  69. git config --global user.email "github-actions[bot]@users.noreply.github.com"
  70. git config --global user.name "github-actions[bot]"
  71. cargo workspaces version -y ${{ env.SEMVER }} --pre-id rc --no-git-commit
  72. # todo: actually just publish!
  73. # cargo workspaces publish -y ${{ github.event.inputs.semver }}
  74. # this will be more useful when we publish the website with updated docs
  75. # Build the docs.rs docs and publish them to the website under the right folder
  76. # v0.4.x -> docs/0.4
  77. # v0.5.x -> docs/0.5 etc
  78. # main -> docs/nightly
  79. # strip the v from the channel, and the .x from the end, and replace main with nightly
  80. # - name: determine docs folder by channel
  81. # id: determine_docs_folder
  82. # run: echo "::set-output name=folder::$(echo ${{ github.event.inputs.channel }} | sed 's/v//g' | sed 's/\.x//g' | sed 's/main/nightly/g')"
  83. # Build the CLI for all platforms, uploading the artifacts to our releases page
  84. release-cli:
  85. needs: release-crates
  86. permissions:
  87. contents: write
  88. strategy:
  89. matrix:
  90. include:
  91. - target: x86_64-pc-windows-msvc
  92. os: windows-latest
  93. - target: aaarch64-pc-windows-msvc
  94. os: windows-latest
  95. - target: x86_64-apple-darwin
  96. os: macos-latest
  97. - target: aarch64-apple-darwin
  98. os: macos-latest
  99. - target: x86_64-unknown-linux-gnu
  100. os: ubuntu-latest
  101. - target: aarch64-unknown-linux-gnu
  102. os: ubuntu-latest
  103. runs-on: ${{ matrix.platform.os }}
  104. steps:
  105. - name: Checkout
  106. uses: actions/checkout@v4
  107. ref: ${{ github.event.inputs.channel }}
  108. - name: Install stable
  109. uses: dtolnay/rust-toolchain@master
  110. with:
  111. toolchain: "1.70.0"
  112. targets: ${{ matrix.platform.target }}
  113. - name: Setup cache
  114. uses: Swatinem/rust-cache@v2
  115. with:
  116. workspaces: packages/cli -> ../../target
  117. - name: Free Disk Space
  118. uses: jlumbroso/free-disk-space@v1.3.1
  119. with: # speed things up a bit
  120. large-packages: false
  121. docker-images: false
  122. swap-storage: false
  123. # Todo: we want `cargo install dx` to actually just use a prebuilt binary instead of building it
  124. - name: Build and upload CLI binaries
  125. uses: taiki-e/upload-rust-binary-action@v1
  126. with:
  127. bin: dx
  128. token: ${{ secrets.GITHUB_TOKEN }}
  129. target: ${{ matrix.platform.target }}
  130. archive: dx-${{ matrix.platform.target }}${{ env.PRERELEASE_TAG }}
  131. checksum: sha256
  132. manifest_path: packages/cli/Cargo.toml
  133. # todo: these things
  134. # Run benchmarks, which we'll use to display on the website
  135. # release-benchmarks:
  136. # Build the vscode extension, uploading the artifact to the marketplace
  137. # release-extension: