release.yml 2.8 KB

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