release.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: Build and Release
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [released]
  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. - name: Gen output name
  34. run: echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  35. - name: Rename Windows File
  36. if: matrix.goos == 'windows'
  37. run: echo "FILENAME=pmail_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  38. - name: FE Build
  39. run: cd fe && yarn && yarn build
  40. - name: BE Build
  41. run: |
  42. cd server && cp -rf ../fe/dist http_server
  43. go build -ldflags "-s -w -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
  44. - name: Upload files to Artifacts
  45. uses: actions/upload-artifact@v3
  46. with:
  47. name: ${{ env.FILENAME }}
  48. path: ./server/${{ env.FILENAME }}
  49. - name: Upload binaries to release
  50. uses: svenstaro/upload-release-action@v2
  51. with:
  52. repo_token: ${{ secrets.GITHUB_TOKEN }}
  53. file: ./server/${{ env.FILENAME }}
  54. tag: ${{ github.ref }}
  55. file_glob: true