diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..88ac845 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,60 @@ +name: Go +on: + push: + tags: + - '*' + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + ref: 'master' + fetch-depth: '0' + + - name: Generate Git log + run: | + git fetch origin +refs/tags/*:refs/tags/* + GITVER=$(git describe --tags) + PREVVER=$(git describe --tags --abbrev=0 ${GITVER}~1) + git log --oneline ${PREVVER}..${GITVER} > gitlogs.txt + + - name: Get dependencies + run: | + go get -v -t -d ./... + + - name: Build + run: | + GITVER=$(git describe --tags || git rev-parse --short HEAD) + LDFLAGS="main.YDAppId=${{ secrets.YDAPPID }} -X main.YDAppSec=${{ secrets.YDAPPSEC }} -X main.MAINVER=${GITVER} -s -w" + GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -v -o ydgo_amd64_linux + GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -v -o ydgo_amd64_darwin + GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -v -o ydgo_amd64_windows.exe + zip ydgo_amd64_linux.zip ydgo_amd64_linux + zip ydgo_amd64_darwin.zip ydgo_amd64_darwin + zip ydgo_amd64_windows.zip ydgo_amd64_windows.exe + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + prerelease: false + draft: false + body_path: gitlogs.txt + files: | + ydgo_amd64_linux.zip + ydgo_amd64_windows.zip + ydgo_amd64_darwin.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/go.mod b/go.mod index 28820b1..cb2c981 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ +go 1.13 + module github.com/boypt/ydgo require (