Skip to content

Commit

Permalink
feat: release workflow (#5)
Browse files Browse the repository at this point in the history
* feat: release workflow

* fix: release

* fix: latest tag

* fix: release tag
  • Loading branch information
zijiren233 authored Dec 19, 2024
1 parent 4b76d4e commit 2316aa5
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions .github/workflows/build.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Build
name: Release

on:
push:
branches:
- "**"
tags:
- "v*"
workflow_dispatch:
- "v*.*.*"
pull_request:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-client:
release-client:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -55,20 +57,27 @@ jobs:
-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: ${{ !startsWith(github.ref, 'refs/tags/') }}
prerelease: false
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' }}
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: |
dist/*
build-server:
release-server:
runs-on: ubuntu-latest

steps:
Expand All @@ -81,6 +90,7 @@ jobs:
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 }}
Expand All @@ -89,17 +99,27 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
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@v5
uses: docker/build-push-action@v6
with:
context: server
push: true
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down

0 comments on commit 2316aa5

Please sign in to comment.