From 3bc5d29324eab06a56eb06f304a0147c273bb892 Mon Sep 17 00:00:00 2001 From: Abid Famasya Date: Mon, 12 Jan 2026 22:43:55 +0700 Subject: [PATCH] add github actions for build and test --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 24 ++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5ab8594 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,55 @@ +name: Build + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + os: + - linux + - windows + - darwin + arch: + - amd64 + - arm64 + include: + - os: linux + arch: arm + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + + - name: Build + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + run: | + binary_name="gdocs-cli" + if [ "${{ matrix.os }}" = "windows" ]; then + binary_name="${binary_name}.exe" + fi + go build -o "${binary_name}" ./cmd/gdocs-cli + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: gdocs-cli-${{ matrix.os }}-${{ matrix.arch }} + path: gdocs-cli + if-no-files-found: error + + - name: Create Release + if: github.ref == format('refs/tags/{0}', github.event.release.tag_name) + uses: softprops/action-gh-release@v2 + with: + files: gdocs-cli* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6dea041 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + cache: true + + - name: Run tests + run: go test ./...