release.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. name: Build and Release
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [published]
  6. jobs:
  7. build:
  8. permissions:
  9. contents: write
  10. strategy:
  11. matrix:
  12. goos: [windows, linux, darwin]
  13. goarch: [amd64, arm64, 386]
  14. exclude:
  15. - goos: darwin
  16. goarch: 386
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Get version
  20. id: get_version
  21. run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  22. - name: Checkout
  23. uses: actions/checkout@v4.0.0
  24. - name: Setup Node.js environment
  25. uses: actions/setup-node@v3.8.1
  26. - name: Install Dependencies
  27. run: npm install --global yarn
  28. - name: Setup Go environment
  29. uses: actions/setup-go@v4.1.0
  30. - name: Gen output name
  31. run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  32. - name: Rename Windows File
  33. if: matrix.goos == 'windows'
  34. run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  35. - name: FE Build
  36. run: cd fe && yarn && yarn build
  37. - name: BE Build
  38. run: |
  39. cd server && cp -rf ../fe/dist http_server
  40. CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} 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
  41. - name: Upload files to Artifacts
  42. uses: actions/upload-artifact@v3
  43. with:
  44. name: ${{ env.FILENAME }}
  45. path: ./output/${{ env.FILENAME }}
  46. - name: Upload binaries to release
  47. uses: svenstaro/upload-release-action@v2
  48. with:
  49. repo_token: ${{ secrets.GITHUB_TOKEN }}
  50. file: ./output/${{ env.FILENAME }}
  51. tag: ${{ github.ref }}
  52. file_glob: true