release.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. name: release
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches:
  6. - master
  7. jobs:
  8. release:
  9. runs-on: ubuntu-latest
  10. permissions: write-all
  11. name: Release
  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. VERSION=$(./scripts/is-newer-version.bash)
  21. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  22. if [ "$VERSION" != "0" ]; then
  23. echo "New version detected: $VERSION"
  24. else
  25. echo "No new version to release"
  26. fi
  27. - name: Push tag
  28. if: steps.version-check.outputs.version != '0'
  29. id: push-tag
  30. run: |
  31. tag="v${{ steps.version-check.outputs.version }}"
  32. git config user.name "${GITHUB_ACTOR}"
  33. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  34. git tag -a "${tag}" -m "Release ${tag}"
  35. git push origin "${tag}"
  36. echo "tag_name=${tag}" >> $GITHUB_OUTPUT
  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: Cache Rust dependencies
  44. if: steps.version-check.outputs.version != '0'
  45. uses: Swatinem/rust-cache@v2
  46. with:
  47. cache-on-failure: "true"
  48. - name: Build project
  49. if: steps.version-check.outputs.version != '0'
  50. run: cargo build --release
  51. shell: bash
  52. working-directory: ${{ github.action_path }}
  53. - name: Generate minimized HTML
  54. if: steps.version-check.outputs.version != '0'
  55. run: cargo run --release -- index.html
  56. shell: bash
  57. working-directory: ${{ github.action_path }}
  58. - name: Copy files
  59. if: steps.version-check.outputs.version != '0'
  60. run: |
  61. mkdir -p ../release
  62. cp -v index.html ../release/
  63. cp -v index.min.html ../release/
  64. cp -v index.allinone.html ../release/
  65. cp -v index.allinone.min.html ../release/
  66. # Misc
  67. cp -v LICENSE ../release/
  68. cp -v README.md ../release/
  69. cp -v README_EN.md ../release/
  70. cp -v CONTRIBUTING.md ../release/
  71. cp -v CNAME ../release/
  72. cp -rv doc ../release/
  73. cp -rv scripts ../release/
  74. cp -rv src ../release/
  75. shell: bash
  76. working-directory: ${{ github.action_path }}
  77. - name: Create release
  78. if: steps.version-check.outputs.version != '0'
  79. uses: ncipollo/release-action@v1
  80. with:
  81. generateReleaseNotes: true
  82. tag: "v${{ steps.version-check.outputs.version }}"
  83. artifacts: "../release/index.html,../release/index.min.html,../release/index.allinone.html,../release/index.allinone.min.html"
  84. - name: Setup Pages
  85. uses: actions/configure-pages@v4
  86. - name: Upload artifact
  87. uses: actions/upload-pages-artifact@v3
  88. with:
  89. path: '../release'
  90. - name: Deploy to GitHub Pages
  91. id: deployment
  92. uses: actions/deploy-pages@v4
  93. - name: Delete tag
  94. if: (cancelled() || failure()) && steps.push-tag.outputs.tag_name != ''
  95. run: |
  96. git config user.name "${GITHUB_ACTOR}"
  97. git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
  98. git push --delete origin "${{ steps.push-tag.outputs.tag_name }}"
  99. git tag -d "${{ steps.push-tag.outputs.tag_name }}"