60 lines
1.9 KiB
YAML
60 lines
1.9 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
release:
|
|
types: [published]
|
|
|
|
|
|
jobs:
|
|
build:
|
|
permissions:
|
|
contents: write
|
|
strategy:
|
|
matrix:
|
|
goos: [windows, linux, darwin]
|
|
goarch: [amd64, arm64, 386]
|
|
exclude:
|
|
- goos: darwin
|
|
goarch: 386
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
CGO_ENABLED: 0
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
steps:
|
|
- name: Get version
|
|
id: get_version
|
|
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
- name: Checkout
|
|
uses: actions/checkout@v4.0.0
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v3.8.1
|
|
- name: Install Dependencies
|
|
run: npm install --global yarn
|
|
- name: Setup Go environment
|
|
uses: actions/setup-go@v4.1.0
|
|
- name: Gen output name
|
|
run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}" >> ${GITHUB_ENV}
|
|
- name: Rename Windows File
|
|
if: matrix.goos == 'windows'
|
|
run: echo "FILENAME=t_${{ matrix.goos }}_${{ matrix.goarch }}.exe" >> ${GITHUB_ENV}
|
|
- name: FE Build
|
|
run: cd fe && yarn && yarn build
|
|
- name: BE Build
|
|
run: |
|
|
cd server && cp -rf ../fe/dist http_server
|
|
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
|
|
- name: Upload files to Artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ env.FILENAME }}
|
|
path: ./output/${{ env.FILENAME }}
|
|
- name: Upload binaries to release
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: ./output/${{ env.FILENAME }}
|
|
tag: ${{ github.ref }}
|
|
file_glob: true
|