Skip to content

Build

Build #3

Workflow file for this run

name: Build
on:
push:
tags:
- "v*"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-client:
runs-on: ubuntu-latest
strategy:
matrix:
targets:
- OS: darwin
ARCH: amd64
EXT: ""
- OS: darwin
ARCH: arm64
EXT: ""
- OS: windows
ARCH: amd64
EXT: .exe
- OS: windows
ARCH: arm64
EXT: .exe
- OS: linux
ARCH: amd64
EXT: ""
- OS: linux
ARCH: arm64
EXT: ""
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Go Build
run: |
export CGO_ENABLED=0
export GOOS=${{ matrix.targets.OS }}
export GOARCH=${{ matrix.targets.ARCH }}
mkdir -p dist
go build \
-trimpath \
-ldflags="-s -w" \
-o dist/wst-${{ matrix.targets.OS }}-${{ matrix.targets.ARCH }}${{ matrix.targets.EXT }} \
./client
- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
append_body: false
fail_on_unmatched_files: true
name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Dev Build' }}
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }}
files: |
dist/*
build-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: server
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}