release.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. env:
  19. CGO_ENABLED: 0
  20. GOOS: ${{ matrix.goos }}
  21. GOARCH: ${{ matrix.goarch }}
  22. steps:
  23. - name: Get version
  24. id: get_version
  25. run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  26. - name: Checkout
  27. uses: actions/checkout@v4.0.0
  28. - name: Setup Node.js environment
  29. uses: actions/setup-node@v3.8.1
  30. - name: Install Dependencies
  31. run: npm install --global yarn
  32. - name: Setup Go environment
  33. uses: actions/setup-go@v4.1.0
  34. - name: Gen output name
  35. run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
  36. - name: Rename Windows File
  37. if: matrix.goos == 'windows'
  38. run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
  39. - name: FE Build
  40. run: cd fe && yarn && yarn build
  41. - name: BE Build
  42. run: |
  43. cd server && cp -rf ../fe/dist http_server
  44. 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
  45. - name: Upload files to Artifacts
  46. uses: actions/upload-artifact@v3
  47. with:
  48. name: ${{ env.FILENAME }}
  49. path: ./output/${{ env.FILENAME }}
  50. - name: Upload binaries to release
  51. uses: svenstaro/upload-release-action@v2
  52. with:
  53. repo_token: ${{ secrets.GITHUB_TOKEN }}
  54. file: ./output/${{ env.FILENAME }}
  55. tag: ${{ github.ref }}
  56. file_glob: true