diff --git a/.github/workflows/go-release.yml b/.github/workflows/go-release.yml new file mode 100644 index 0000000..4d9394e --- /dev/null +++ b/.github/workflows/go-release.yml @@ -0,0 +1,41 @@ +# .github/workflows/release.yaml + +on: + release: + types: [created] + +permissions: + contents: write + packages: write + +jobs: + releases-matrix: + name: Release Go Binary + runs-on: ubuntu-latest + strategy: + matrix: + # build and publish in parallel: + # linux/386, linux/amd64, linux/arm64, + # windows/386, windows/amd64, + # darwin/amd64, darwin/arm64 + goos: [linux, windows, darwin] + goarch: [amd64, arm64] + exclude: + - goarch: arm64 + goos: windows + steps: + - uses: actions/checkout@v4 + - name: Set BUILD_TIME env + run: echo BUILD_TIME=$(date -u --rfc-3339=seconds) >> ${GITHUB_ENV} + + - uses: wangyoucao577/go-release-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + ldflags: | + -X "main.buildTime=${{ env.BUILD_TIME }}" + -X main.gitCommit=${{ github.sha }} + -X main.gitRef=${{ github.ref }} + -X main.gitRefName=${{ github.ref_name }} + -X main.gitRefType=${{ github.ref_type }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..01adbf8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test the code + +on: + push: + branches: ["*"] + pull_request: + branches: ["master"] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + + - name: Run Go tests + run: go test -v ./...