name: Build on: push: branches: [master] tags: [v*] permissions: contents: write jobs: goreleaser: name: Goreleaser runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Fetch all tags run: git fetch --force --tags - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.22' - name: Run GoReleaser uses: goreleaser/goreleaser-action@v5 if: ${{ contains(github.ref, 'v') }} with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test GoReleaser uses: goreleaser/goreleaser-action@v5 if: ${{ ! contains(github.ref, 'v') }} with: # either 'goreleaser' (default) or 'goreleaser-pro' distribution: goreleaser version: latest args: release --snapshot --clean build: name: Build-${{ matrix.os }}-${{ matrix.GOARCH }} runs-on: ${{ matrix.os }} strategy: matrix: os: - windows-latest - ubuntu-latest - macos-latest GOARCH: - amd64 include: - os: ubuntu-latest GOARCH: "386" - os: ubuntu-latest GOARCH: "arm" - os: ubuntu-latest GOARCH: "arm64" - os: ubuntu-latest GOARCH: "riscv64" - os: macos-latest GOARCH: "arm64" steps: - name: Check out uses: actions/checkout@v4 - name: Set up Go 1.22 uses: actions/setup-go@v5 with: go-version: '1.22' - name: Get git tag ref run: git fetch --prune --unshallow --tags - name: Download dependencies run: go mod download - name: Generate version run: go generate ./cmd/go-judge/version - name: Build on Linux if: ${{ matrix.os == 'ubuntu-latest' }} env: GOARCH: ${{ matrix.GOARCH }} CGO_ENABLE: 0 run: | go build -v -tags grpcnotrace,nomsgpack -o go-judge ./cmd/go-judge go build -v -o go-judge-shell ./cmd/go-judge-shell go build -o go-judge-init ./cmd/go-judge-init - name: Build shared objects on Linux if: ${{ matrix.os == 'ubuntu-latest' && matrix.GOARCH == 'amd64' }} env: GOARCH: ${{ matrix.GOARCH }} run: | go build -buildmode=c-shared -o go-judge.so ./cmd/go-judge-ffi - name: Upload go-judge on linux if: ${{ matrix.os == 'ubuntu-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-${{ matrix.GOARCH }} path: go-judge - name: Upload go-judge-shell on linux if: ${{ matrix.os == 'ubuntu-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-shell-${{ matrix.GOARCH }} path: go-judge-shell - name: Upload go-judge-init on linux if: ${{ matrix.os == 'ubuntu-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-init-${{ matrix.GOARCH }} path: go-judge-init - name: Upload go-judge.so on linux if: ${{ matrix.os == 'ubuntu-latest' && matrix.GOARCH == 'amd64' }} uses: actions/upload-artifact@v4 with: name: go-judge-${{ matrix.GOARCH }}.so path: go-judge.so - name: Build on Windows if: ${{ matrix.os == 'windows-latest' }} env: GOARCH: ${{ matrix.GOARCH }} run: | go build -tags grpcnotrace,nomsgpack -o go-judge.exe ./cmd/go-judge - name: Build shared object on Windows if: ${{ matrix.os == 'windows-latest' }} env: GOARCH: ${{ matrix.GOARCH }} run: | go build -buildmode=c-shared -o go-judge.dll ./cmd/go-judge-ffi - name: Upload go-judge.exe on Windows if: ${{ matrix.os == 'windows-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-${{ matrix.GOARCH }}.exe path: go-judge.exe - name: Upload go-judge.dll on Windows if: ${{ matrix.os == 'windows-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-${{ matrix.GOARCH }}.dll path: go-judge.dll - name: Build on macOS if: ${{ matrix.os == 'macos-latest' }} env: GOARCH: ${{ matrix.GOARCH }} run: | go build -tags grpcnotrace,nomsgpack -o go-judge ./cmd/go-judge go build -o go-judge-shell ./cmd/go-judge-shell - name: Build shared object on macOS if: ${{ matrix.os == 'macos-latest' && matrix.GOARCH == 'amd64' }} env: GOARCH: ${{ matrix.GOARCH }} run: | go build -buildmode=c-shared -o go-judge.dylib ./cmd/go-judge-ffi - name: Upload go-judge on macOS if: ${{ matrix.os == 'macos-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-MacOS-${{ matrix.GOARCH }} path: go-judge - name: Upload go-judge-shell on macOS if: ${{ matrix.os == 'macos-latest' }} uses: actions/upload-artifact@v4 with: name: go-judge-shell-MacOS-${{ matrix.GOARCH }} path: go-judge-shell - name: Upload go-judge.dylib on macOS if: ${{ matrix.os == 'macos-latest' && matrix.GOARCH == 'amd64' }} uses: actions/upload-artifact@v4 with: name: go-judge-${{ matrix.GOARCH }}.dylib path: go-judge.dylib