release.yml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. name: release
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - master
  7. jobs:
  8. checks:
  9. name: Checks
  10. uses: ./.github/workflows/checks.yml
  11. release:
  12. runs-on: ubuntu-latest
  13. permissions: write-all
  14. name: Release
  15. steps:
  16. - name: Checkout
  17. uses: actions/checkout@v4
  18. with:
  19. fetch-depth: 0
  20. - name: Check version
  21. id: version-check
  22. run: |
  23. VERSION=$(./scripts/is-newer-version.bash)
  24. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  25. if [ "$VERSION" != "0" ]; then
  26. echo "New version detected: $VERSION"
  27. else
  28. echo "No new version to release"
  29. fi
  30. - name: Push tag
  31. if: steps.version-check.outputs.version != '0'
  32. id: push-tag
  33. run: |
  34. tag="v${{ steps.version-check.outputs.version }}"
  35. git config user.name "${GITHUB_ACTOR}"
  36. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  37. git tag -a "${tag}" -m "Release ${tag}"
  38. git push origin "${tag}"
  39. echo "tag_name=${tag}" >> $GITHUB_OUTPUT
  40. - name: Checkout
  41. if: steps.version-check.outputs.version != '0'
  42. uses: actions/checkout@v4
  43. - name: Setup Rust
  44. if: steps.version-check.outputs.version != '0'
  45. uses: MatteoH2O1999/setup-rust@v1
  46. - name: Cache Rust dependencies
  47. if: steps.version-check.outputs.version != '0'
  48. uses: Swatinem/rust-cache@v2
  49. with:
  50. cache-on-failure: "true"
  51. - name: Build project
  52. if: steps.version-check.outputs.version != '0'
  53. run: cargo build --release
  54. shell: bash
  55. - name: Create release
  56. if: steps.version-check.outputs.version != '0'
  57. uses: ncipollo/release-action@v1
  58. with:
  59. generateReleaseNotes: true
  60. tag: "v${{ steps.version-check.outputs.version }}"
  61. artifacts: "./target/release/swb-sys-monitor"
  62. - name: Publish project
  63. if: steps.version-check.outputs.version != '0'
  64. run: |
  65. ./scripts/publish-crates-io.bash -n ${{ secrets.CRATES_IO_TOKEN }} # Dry run check
  66. ./scripts/publish-crates-io.bash -y ${{ secrets.CRATES_IO_TOKEN }} # Actual publish with auto-confirm
  67. shell: bash
  68. # - name: Setup Pages
  69. # uses: actions/configure-pages@v4
  70. # - name: Upload artifact
  71. # uses: actions/upload-pages-artifact@v3
  72. # with:
  73. # path: ""
  74. # - name: Deploy to GitHub Pages
  75. # id: deployment
  76. # uses: actions/deploy-pages@v4
  77. - name: Delete tag if failure or cancelled
  78. if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
  79. run: |
  80. git config user.name "${GITHUB_ACTOR}"
  81. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  82. git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
  83. git tag -d "${{ steps.push-tag.outputs.tag_name }}"