From d65df1eafec5e42988a8282607475a23291f1261 Mon Sep 17 00:00:00 2001 From: i3h Date: Tue, 21 Jul 2020 10:56:37 +0800 Subject: [PATCH] Update workflow --- .github/workflows/main.yml | 53 ++++++++++++++++++++------------------ cmd/tcping/main.go | 2 +- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22e8eba..d7e894d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,11 @@ jobs: publish_release: runs-on: ubuntu-latest steps: - # checkout code - - uses: actions/checkout@master - # create release - - uses: actions/create-release@v1 + - name: Checkout code + uses: actions/checkout@master + + - name: Create release + uses: actions/create-release@v1 id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -23,37 +24,39 @@ jobs: Changes in this Release - First Change - Second Change - draft: false - prerelease: false - # build binaries - - uses: actions/setup-go@v1 + draft: true + prerelease: true + + - name: Setup Go + uses: actions/setup-go@v1 with: go-version: '1.13.5' - - name: build + + - name: Build run: | - mkdir tcping-linux-amd64 - mkdir tcping-darwin-amd64 - env VERSION=$(echo ${GITHUB_REF:10}) GIN_MODE=release GOOS=linux GOARCH=amd64 bash -c 'go build -ldflags "-X main.VersionString=$VERSION" -o tcping-linux-amd64/tcping *.go' - env VERSION=$(echo ${GITHUB_REF:10}) GIN_MODE=release GOOS=darwin GOARCH=amd64 bash -c 'go build -ldflags "-X main.VersionString=$VERSION" -o tcping-darwin-amd64/tcping *.go' - tar -C $PWD -cvzf tcping-linux-amd64.tar.gz tcping-linux-amd64 - tar -C $PWD -cvzf tcping-darwin-amd64.tar.gz tcping-darwin-amd64 - # upload binaries linux - - uses: actions/upload-release-asset@v1.0.1 + cd cmd/tcping + env VERSION=$(echo ${GITHUB_REF:10}) GIN_MODE=release GOOS=linux GOARCH=amd64 bash -c 'go build -ldflags "-X main.VersionString=$VERSION" -o tcping-linux-amd64 *.go' + env VERSION=$(echo ${GITHUB_REF:10}) GIN_MODE=release GOOS=darwin GOARCH=amd64 bash -c 'go build -ldflags "-X main.VersionString=$VERSION" -o tcping-darwin-amd64 *.go' + ls -lha + + - name: Upload binary linux + uses: actions/upload-release-asset@v1.0.1 id: upload-release-asset-linux env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./tcping-linux-amd64.tar.gz - asset_name: tcping-linux-amd64.tar.gz - asset_content_type: application/gzip - # upload binaries darwin - - uses: actions/upload-release-asset@v1.0.1 + asset_path: ./cmd/tcping/tcping-linux-amd64 + asset_name: tcping-linux-amd64 + asset_content_type: application/octet-stream + + - name: Upload binary darwin + uses: actions/upload-release-asset@v1.0.1 id: upload-release-asset-darwin env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./tcping-darwin-amd64.tar.gz - asset_name: tcping-darwin-amd64.tar.gz - asset_content_type: application/gzip + asset_path: ./cmd/tcping/tcping-darwin-amd64 + asset_name: tcping-darwin-amd64 + asset_content_type: application/octet-stream diff --git a/cmd/tcping/main.go b/cmd/tcping/main.go index 9bc3290..4ce4496 100644 --- a/cmd/tcping/main.go +++ b/cmd/tcping/main.go @@ -13,7 +13,7 @@ import ( ) var ( - VersionString string = "v1.1.0" + VersionString string ) func init() {