From 2deb25de7ca8e808fa743df4ded59eb69728eb1e Mon Sep 17 00:00:00 2001 From: Duncan Leo Date: Sun, 17 Dec 2023 10:55:48 +0800 Subject: [PATCH] build(ci): Add workflow for building PRs (PR: #19) * build(ci): update actions * build(ci): use Go v1.21 * build(ci): add workflow to test building --- .github/workflows/main.yml | 14 +++++++------- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73a8558..d7fb5ca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,18 +9,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code into the Go module directory - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Set up Go 1.17 - uses: actions/setup-go@v2 + - name: Set up Golang + uses: actions/setup-go@v4 with: - go-version: 1.17 + go-version: 1.21 id: go - - name: Use Node.js 14.x - uses: actions/setup-node@v2 + - name: Use Node.js 20.x + uses: actions/setup-node@v4 with: - node-version: 14.x + node-version: 20.x - name: Extract branch name shell: bash diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a933f43 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Test Build + +on: + pull_request: + types: [synchronize] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Set up Golang + uses: actions/setup-go@v4 + with: + go-version: 1.21 + id: go + - name: Get dependencies + run: | + go mod download + - name: Build + run: | + GOOS=linux GOARCH=amd64 go build -v -o ${GITHUB_REPOSITORY##*/}-linux-x64 ./cmd/... + GOOS=linux GOARCH=arm GOARM=5 go build -v -o ${GITHUB_REPOSITORY##*/}-linux-armv5 ./cmd/... + GOOS=linux GOARCH=arm64 go build -v -o ${GITHUB_REPOSITORY##*/}-linux-arm64 ./cmd/... + GOOS=darwin GOARCH=amd64 go build -v -o ${GITHUB_REPOSITORY##*/}-darwin-amd64 ./cmd/... + GOOS=darwin GOARCH=arm64 go build -v -o ${GITHUB_REPOSITORY##*/}-darwin-arm64 ./cmd/... + GOOS=windows GOARCH=amd64 go build -v -o ${GITHUB_REPOSITORY##*/}-windows-amd64.exe ./cmd/... + GOOS=windows GOARCH=386 go build -v -o ${GITHUB_REPOSITORY##*/}-windows-i386.exe ./cmd/... + GOOS=windows GOARCH=arm go build -v -o ${GITHUB_REPOSITORY##*/}-windows-arm.exe ./cmd/... + GOOS=windows GOARCH=arm64 go build -v -o ${GITHUB_REPOSITORY##*/}-windows-arm64.exe ./cmd/...