From 29948d3c06f1283017312af309af68a4c00b3169 Mon Sep 17 00:00:00 2001 From: Sense T Date: Tue, 23 Apr 2024 13:18:10 +0800 Subject: [PATCH] ci-test --- .github/workflows/docker-publish.yml | 4 +- .github/workflows/go.yml | 79 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 9bc9d58..268ecaa 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,11 +7,9 @@ name: Docker on: push: - branches: [ "master" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] - pull_request: - branches: [ "master" ] + env: # Use docker.io for Docker Hub if empty diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..42a0a67 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,79 @@ +name: Go + +on: + push: + tags: + - 'v*.*.*' + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up NodeJS + uses: actions/setup-node@v4 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.22 + + - name: Build Web UI + run: | + cd web + npm i && npm run build + cd .. + go generate ./... + + - name: Build-linux-amd64 + env: + GOOS: linux + GOARCH: amd64 + run: | + mkdir -p recored-ui-${GOOS}-${GOARCH} + go build -trimpath -ldflags "-w -s" -v -o ./recored-ui-${GOOS}-${GOARCH} ./... + tar czvf recored-ui-${GOOS}-${GOARCH}.tgz recored-ui-${GOOS}-${GOARCH} + + - name: Build-linux-arm64 + env: + GOOS: linux + GOARCH: arm64 + run: | + mkdir -p recored-ui-${GOOS}-${GOARCH} + go build -trimpath -ldflags "-w -s" -v -o ./recored-ui-${GOOS}-${GOARCH} ./... + tar czvf recored-ui-${GOOS}-${GOARCH}.tgz recored-ui-${GOOS}-${GOARCH} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Release Asset Linux arm64 + id: upload-release-asset-linux-arm + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ github.workspace }}/recored-ui-linux-arm64.tgz + asset_name: recored-ui-linux-arm64.tgz + asset_content_type: application/x-gzip + + - name: Upload Release Asset Linux amd64 + id: upload-release-asset-linux-amd64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ github.workspace }}/recored-ui-linux-amd64.tgz + asset_name: recored-ui-linux-amd64.tgz + asset_content_type: application/x-gzip