mirror of
https://github.com/criyle/go-judge.git
synced 2025-11-04 14:50:02 +08:00
186 lines
5.9 KiB
YAML
186 lines
5.9 KiB
YAML
name: Build
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
tags: [v*]
|
|
permissions:
|
|
contents: write
|
|
jobs:
|
|
goreleaser:
|
|
name: Goreleaser
|
|
runs-on: ubuntu-latest
|
|
if: ${{ contains(github.ref, 'v') }}
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
-
|
|
name: Fetch all tags
|
|
run: git fetch --force --tags
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
-
|
|
name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
-
|
|
name: Set up Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.20'
|
|
-
|
|
name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v3
|
|
with:
|
|
# either 'goreleaser' (default) or 'goreleaser-pro'
|
|
distribution: goreleaser
|
|
version: latest
|
|
args: release --rm-dist
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
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: macos-latest
|
|
GOARCH: "arm64"
|
|
steps:
|
|
- name: Set up Go 1.20
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.20'
|
|
- name: Check out
|
|
uses: actions/checkout@v3
|
|
- name: Get git tag ref
|
|
run: git fetch --prune --unshallow --tags
|
|
- name: Restore Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
- name: Generate version
|
|
run: go generate ./cmd/executorserver/version
|
|
|
|
- name: Build on Linux
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
env:
|
|
GOARCH: ${{ matrix.GOARCH }}
|
|
CGO_ENABLE: 0
|
|
run: |
|
|
go build -v -tags nomsgpack -o executorserver ./cmd/executorserver
|
|
go build -v -o executorshell ./cmd/executorshell
|
|
go build -o cinit ./cmd/cinit
|
|
- 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 executorserver.so ./cmd/ffi
|
|
- name: Upload executorserver on linux
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorServer-${{ matrix.GOARCH }}
|
|
path: executorserver
|
|
- name: Upload executorshell on linux
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorShell-${{ matrix.GOARCH }}
|
|
path: executorshell
|
|
- name: Upload cinit on linux
|
|
if: ${{ matrix.os == 'ubuntu-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: cinit-${{ matrix.GOARCH }}
|
|
path: cinit
|
|
- name: Upload executorserver.so on linux
|
|
if: ${{ matrix.os == 'ubuntu-latest' && matrix.GOARCH == 'amd64' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorServer-${{ matrix.GOARCH }}.so
|
|
path: executorserver.so
|
|
|
|
- name: Build on Windows
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
env:
|
|
GOARCH: ${{ matrix.GOARCH }}
|
|
run: |
|
|
go build -tags nomsgpack -o executorserver.exe ./cmd/executorserver
|
|
- name: Build shared object on Windows
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
env:
|
|
GOARCH: ${{ matrix.GOARCH }}
|
|
run: |
|
|
go build -buildmode=c-shared -o executorserver.dll ./cmd/ffi
|
|
- name: Upload executorserver.exe on Windows
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorServer-${{ matrix.GOARCH }}.exe
|
|
path: executorserver.exe
|
|
- name: Upload executorserver.dll on Windows
|
|
if: ${{ matrix.os == 'windows-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorServer-${{ matrix.GOARCH }}.dll
|
|
path: executorserver.dll
|
|
|
|
- name: Build on macOS
|
|
if: ${{ matrix.os == 'macos-latest' }}
|
|
env:
|
|
GOARCH: ${{ matrix.GOARCH }}
|
|
run: |
|
|
go build -tags nomsgpack -o executorserver ./cmd/executorserver
|
|
go build -o executorshell ./cmd/executorshell
|
|
- 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 executorserver.dylib ./cmd/ffi
|
|
- name: Upload executorserver on macOS
|
|
if: ${{ matrix.os == 'macos-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorServer-MacOS-${{ matrix.GOARCH }}
|
|
path: executorserver
|
|
- name: Upload executorshell on macOS
|
|
if: ${{ matrix.os == 'macos-latest' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorShell-MacOS-${{ matrix.GOARCH }}
|
|
path: executorshell
|
|
- name: Upload executorserver.dylib on macOS
|
|
if: ${{ matrix.os == 'macos-latest' && matrix.GOARCH == 'amd64' }}
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ExecutorServer-${{ matrix.GOARCH }}.dylib
|
|
path: executorserver.dylib
|