Build Go SDK #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Test Go SDK and tag Go module for publishing. | |
| # | |
| # Downloads the prebuilt native library from GitHub Releases, then builds | |
| # and tests the Go SDK — validating the same workflow that end users follow. | |
| # | |
| # User workflow: | |
| # go get github.com/boxlite-ai/boxlite/sdks/go | |
| # go run github.com/boxlite-ai/boxlite/sdks/go/cmd/setup | |
| # go build ./... | |
| # | |
| # Triggers: | |
| # - workflow_run: After Build C SDK completes (ensures archives are uploaded) | |
| # - workflow_dispatch: Manual trigger for testing | |
| name: Build Go SDK | |
| on: | |
| workflow_run: | |
| workflows: ["Build C SDK"] | |
| types: [completed] | |
| workflow_dispatch: | |
| jobs: | |
| config: | |
| uses: ./.github/workflows/config.yml | |
| test: | |
| name: Test (${{ matrix.target }}) | |
| needs: config | |
| if: >- | |
| github.event_name != 'workflow_run' || | |
| github.event.workflow_run.conclusion == 'success' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.config.outputs.platforms) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ needs.config.outputs.go-version }} | |
| - name: Download prebuilt library | |
| run: | | |
| VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') | |
| PLATFORM="${{ matrix.target }}" | |
| ARCHIVE="boxlite-c-v${VERSION}-${PLATFORM}.tar.gz" | |
| URL="https://github.com/boxlite-ai/boxlite/releases/download/v${VERSION}/${ARCHIVE}" | |
| echo "Downloading: ${URL}" | |
| curl -sL "${URL}" | tar xz -C /tmp/ | |
| cp "/tmp/boxlite-c-v${VERSION}-${PLATFORM}/lib/libboxlite.a" sdks/go/ | |
| - name: Test Go SDK | |
| run: | | |
| cd sdks/go | |
| go build ./... | |
| go test -v ./... | |
| tag-go-module: | |
| name: Tag Go Module | |
| needs: test | |
| if: github.event_name == 'workflow_run' && github.event.workflow_run.event == 'release' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Create Go module tag | |
| run: | | |
| VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') | |
| TAG="sdks/go/v${VERSION}" | |
| echo "Creating tag: ${TAG}" | |
| if git rev-parse "${TAG}" >/dev/null 2>&1; then | |
| echo "Tag ${TAG} already exists, skipping" | |
| exit 0 | |
| fi | |
| git tag "${TAG}" | |
| git push origin "${TAG}" |