release.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: Build and Release
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [released,prereleased]
  6. jobs:
  7. build:
  8. permissions:
  9. contents: write
  10. strategy:
  11. matrix:
  12. goos: [windows, linux, darwin]
  13. goarch: [amd64, arm64]
  14. runs-on: ubuntu-latest
  15. env:
  16. CGO_ENABLED: 0
  17. GOOS: ${{ matrix.goos }}
  18. GOARCH: ${{ matrix.goarch }}
  19. steps:
  20. - name: Get version
  21. id: get_version
  22. run: |
  23. echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  24. echo "${GITHUB_REF}"
  25. - name: Checkout
  26. uses: actions/checkout@v4.0.0
  27. - name: Setup Node.js environment
  28. uses: actions/setup-node@v3.8.1
  29. - name: Install Dependencies
  30. run: npm install --global yarn
  31. - name: Setup Go environment
  32. uses: actions/setup-go@v4.1.0
  33. with:
  34. check-latest: true
  35. - name: Gen output name
  36. run: |
  37. echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  38. echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  39. echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  40. echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  41. - name: Rename Windows File
  42. if: matrix.goos == 'windows'
  43. run: |
  44. echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  45. echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  46. echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  47. echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  48. - name: FE Build
  49. run: cd fe && yarn && yarn build
  50. - name: BE Build
  51. run: |
  52. cd server && cp -rf ../fe/dist http_server
  53. go build -ldflags "-s -w -X 'main.version=${{ env.VERSION }}' -X 'main.goVersion=$(go version)' -X 'main.gitHash=$(git show -s --format=%H)' -X 'main.buildTime=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)'" -o ${{ env.FILENAME }} main.go
  54. go build -ldflags "-s -w" -o ${{ env.TGFILENAME }} hooks/telegram_push/telegram_push.go
  55. go build -ldflags "-s -w" -o ${{ env.WEBFILENAME }} hooks/web_push/web_push.go
  56. go build -ldflags "-s -w" -o ${{ env.WCFILENAME }} hooks/wechat_push/wechat_push.go
  57. - name: Upload files to Artifacts
  58. uses: actions/upload-artifact@v3
  59. with:
  60. name: ${{ env.FILENAME }}
  61. path: |
  62. ./server/${{ env.FILENAME }}
  63. ./server/${{ env.TGFILENAME }}
  64. ./server/${{ env.WEBFILENAME }}
  65. ./server/${{ env.WCFILENAME }}
  66. - name: Upload binaries to release
  67. uses: svenstaro/upload-release-action@v2
  68. with:
  69. repo_token: ${{ secrets.GITHUB_TOKEN }}
  70. file: |
  71. ./server/${{ env.FILENAME }}
  72. ./server/${{ env.TGFILENAME }}
  73. ./server/${{ env.WEBFILENAME }}
  74. ./server/${{ env.WCFILENAME }}
  75. tag: ${{ github.ref }}
  76. file_glob: true