Skip to content

feat: release workflow #1

feat: release workflow

feat: release workflow #1

Workflow file for this run

name: Release
on:
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release-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: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.targets.OS }}-${{ matrix.targets.ARCH }}
path: dist/*
- name: Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
append_body: false
fail_on_unmatched_files: true
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: |
dist/*
release-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
if: github.event_name != 'pull_request'
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@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: server
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}