1
0

release.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. id: push-tag
  32. run: |
  33. tag="v${{ steps.version-check.outputs.version }}"
  34. git config user.name "${GITHUB_ACTOR}"
  35. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  36. git tag -a "${tag}" -m "Release ${tag}"
  37. git push origin "${tag}"
  38. echo "tag_name=${tag}" >> $GITHUB_OUTPUT
  39. - name: Checkout
  40. if: steps.version-check.outputs.version != '0'
  41. uses: actions/checkout@v4
  42. - name: Setup Rust
  43. if: steps.version-check.outputs.version != '0'
  44. uses: MatteoH2O1999/setup-rust@v1
  45. - name: Build project
  46. if: steps.version-check.outputs.version != '0'
  47. run: cargo build --release
  48. shell: bash
  49. working-directory: ${{ github.action_path }}
  50. - name: Generate minimized HTML
  51. if: steps.version-check.outputs.version != '0'
  52. run: cargo run --release -- index.html
  53. shell: bash
  54. working-directory: ${{ github.action_path }}
  55. - name: Copy files
  56. if: steps.version-check.outputs.version != '0'
  57. run: |
  58. mkdir -p ../release
  59. cp -v index.html ../release/
  60. cp -v index.min.html ../release/
  61. cp -v index.allinone.html ../release/
  62. cp -v index.allinone.min.html ../release/
  63. shell: bash
  64. working-directory: ${{ github.action_path }}
  65. - name: Create release
  66. if: steps.version-check.outputs.version != '0'
  67. uses: ncipollo/release-action@v1
  68. with:
  69. generateReleaseNotes: true
  70. tag: "v${{ steps.version-check.outputs.version }}"
  71. artifacts: "../release/index.html,../release/index.min.html,../release/index.allinone.html,../release/index.allinone.min.html"
  72. - name: Delete tag on failure
  73. if: 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 }}"