release.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: release
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - main
  7. jobs:
  8. release:
  9. runs-on: ubuntu-latest
  10. permissions: write-all
  11. name: Export
  12. steps:
  13. - name: Checkout
  14. uses: actions/checkout@v4
  15. with:
  16. fetch-depth: 0
  17. - name: Check version
  18. id: version-check
  19. run: |
  20. chmod +x ./scripts/is-newer-version.bash
  21. chmod +x ./scripts/get-version.bash
  22. VERSION=$(./scripts/is-newer-version.bash)
  23. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  24. if [ "$VERSION" != "0" ]; then
  25. echo "New version detected: $VERSION"
  26. else
  27. echo "No new version to release"
  28. fi
  29. - name: Push tag
  30. if: steps.version-check.outputs.version != '0'
  31. run: |
  32. tag="v${{ steps.version-check.outputs.version }}"
  33. git config user.name "${GITHUB_ACTOR}"
  34. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  35. git tag -a "${tag}" -m "Release ${tag}"
  36. git push origin "${tag}"
  37. - name: Checkout
  38. if: steps.version-check.outputs.version != '0'
  39. uses: actions/checkout@v4
  40. - name: Setup Rust
  41. if: steps.version-check.outputs.version != '0'
  42. uses: MatteoH2O1999/setup-rust@v1
  43. - name: Build project
  44. if: steps.version-check.outputs.version != '0'
  45. run: cargo build --release
  46. shell: bash
  47. working-directory: ${{ github.action_path }}
  48. - name: Generate minimized HTML
  49. if: steps.version-check.outputs.version != '0'
  50. run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
  51. shell: bash
  52. working-directory: ${{ github.action_path }}
  53. - name: Create release
  54. if: steps.version-check.outputs.version != '0'
  55. uses: ncipollo/release-action@v1
  56. with:
  57. token: ${{ secrets.TOKEN }}
  58. generateReleaseNotes: true
  59. tag: "v${{ steps.version-check.outputs.version }}"
  60. artifacts: "index.html,index.min.html"