release.yml 1.8 KB

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