release.yml 3.2 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. echo "ZIPNAME=${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  42. - name: Rename Windows File
  43. if: matrix.goos == 'windows'
  44. run: |
  45. echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  46. echo "TGFILENAME=telegram_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  47. echo "WCFILENAME=wechat_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  48. echo "WEBFILENAME=web_push_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  49. - name: FE Build
  50. run: cd fe && yarn && yarn build
  51. - name: BE Build
  52. run: |
  53. cd server && cp -rf ../fe/dist http_server
  54. 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
  55. go build -ldflags "-s -w" -o ${{ env.TGFILENAME }} hooks/telegram_push/telegram_push.go
  56. go build -ldflags "-s -w" -o ${{ env.WEBFILENAME }} hooks/web_push/web_push.go
  57. go build -ldflags "-s -w" -o ${{ env.WCFILENAME }} hooks/wechat_push/wechat_push.go
  58. ls -alh
  59. - name: Zip
  60. run: |
  61. ls ./server
  62. zip ${{ env.ZIPNAME }}.zip ./server/${{ env.FILENAME }} ./server/${{ env.TGFILENAME }} ./server/${{ env.WEBFILENAME }} ./server/${{ env.WCFILENAME }}
  63. ls
  64. ls ./server
  65. - name: Upload files to Artifacts
  66. uses: actions/upload-artifact@v3
  67. with:
  68. name: ${{ env.ZIPNAME }}
  69. path: ${{ env.ZIPNAME }}.zip
  70. - name: Upload binaries to release
  71. uses: svenstaro/upload-release-action@v2
  72. with:
  73. repo_token: ${{ secrets.GITHUB_TOKEN }}
  74. file: ${{ env.ZIPNAME }}.zip
  75. tag: ${{ github.ref }}
  76. file_glob: true