1
0

release.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: Copy files
  54. if: steps.version-check.outputs.version != '0'
  55. run: |
  56. mkdir -p ../release
  57. cp -v ${{ github.action_path }}/index.html ../release/
  58. cp -v ${{ github.action_path }}/index.min.html ./release/
  59. shell: bash
  60. working-directory: ${{ github.action_path }}
  61. - name: Create release
  62. if: steps.version-check.outputs.version != '0'
  63. uses: ncipollo/release-action@v1
  64. with:
  65. generateReleaseNotes: true
  66. tag: "v${{ steps.version-check.outputs.version }}"
  67. artifacts: "${{ github.action_path }}/index.html,${{ github.action_path }}/index.min.html"