1
0

release.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 index.min.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. shell: bash
  62. working-directory: ${{ github.action_path }}
  63. - name: Create release
  64. if: steps.version-check.outputs.version != '0'
  65. uses: ncipollo/release-action@v1
  66. with:
  67. generateReleaseNotes: true
  68. tag: "v${{ steps.version-check.outputs.version }}"
  69. artifacts: "../release/index.html,../release/index.min.html"
  70. - name: Delete tag on failure
  71. if: failure() && steps.push-tag.outputs.tag_name != ''
  72. run: |
  73. git config user.name "${GITHUB_ACTOR}"
  74. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  75. git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
  76. git tag -d "${{ steps.push-tag.outputs.tag_name }}"