Skip to content

refactor: extract TemplateEngine to pipeline/ package, decouple plugi… #89

refactor: extract TemplateEngine to pipeline/ package, decouple plugi…

refactor: extract TemplateEngine to pipeline/ package, decouple plugi… #89

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_call:
inputs:
tag_name:
description: 'Tag name to release (e.g. v1.2.3)'
required: true
type: string
secrets:
repo_dispatch_token:
required: true
permissions:
contents: write
packages: write
env:
GOPRIVATE: github.com/GoCodeAlone/*
GONOSUMCHECK: github.com/GoCodeAlone/*
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
jobs:
test:
name: Pre-release Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Build UI assets (required for Go embed)
run: |
cd ui && npm ci && npm run build
cd .. && mkdir -p module/ui_dist && cp -r ui/dist/* module/ui_dist/
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: go test -race ./...
build-ui:
name: Build Admin UI
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Install dependencies
run: cd ui && npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build admin UI
run: cd ui && npm run build
- name: Package admin UI
run: |
VERSION=${TAG_NAME}
tar -czf "workflow-admin-ui-${VERSION}.tar.gz" -C ui dist
echo "UI_TARBALL=workflow-admin-ui-${VERSION}.tar.gz" >> "$GITHUB_ENV"
- name: Upload UI artifact
uses: actions/upload-artifact@v4
with:
name: admin-ui
path: workflow-admin-ui-*.tar.gz
retention-days: 1
docker:
name: Build & Push Container Image (ko)
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
packages: write
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Build UI assets (required for Go embed)
run: |
cd ui && npm ci && npm run build
cd .. && mkdir -p module/ui_dist && cp -r ui/dist/* module/ui_dist/
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up ko
uses: ko-build/setup-ko@v0.9
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | ko login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Build and push
env:
GOPRIVATE: github.com/GoCodeAlone/*
GONOSUMCHECK: github.com/GoCodeAlone/*
GOFLAGS: -mod=mod
run: |
export KO_DOCKER_REPO="ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')"
VERSION="${TAG_NAME#v}"
CORE_VERSION="${VERSION%%[-+]*}"
MAJOR_MINOR="$(echo "$CORE_VERSION" | cut -d. -f1-2)"
SHA_SHORT="${GITHUB_SHA:0:7}"
ko build ./cmd/server \
--bare \
--platform=linux/amd64,linux/arm64 \
--tags="${TAG_NAME},${VERSION},${MAJOR_MINOR},sha-${SHA_SHORT}" \
--sbom=spdx \
--image-refs=/tmp/image-refs.txt
echo "Pushed images:"
cat /tmp/image-refs.txt
build-binaries:
name: Build ${{ matrix.name }} binaries
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
include:
- name: server
cmd: ./cmd/server
prefix: workflow
platforms: linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
build_ui: true
- name: wfctl
cmd: ./cmd/wfctl
prefix: wfctl
platforms: linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
- name: lsp-server
cmd: ./cmd/workflow-lsp-server
prefix: workflow-lsp-server
platforms: linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
- name: Set up Node.js
if: matrix.build_ui
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: Build UI assets (required for Go embed)
if: matrix.build_ui
run: |
cd ui && npm ci && npm run build
cd .. && mkdir -p module/ui_dist && cp -r ui/dist/* module/ui_dist/
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build binaries
run: |
mkdir -p dist
VERSION=${TAG_NAME}
LDFLAGS="-s -w -X main.version=${VERSION}"
for platform in ${{ matrix.platforms }}; do
GOOS="${platform%/*}"
GOARCH="${platform#*/}"
output="dist/${{ matrix.prefix }}-${GOOS}-${GOARCH}"
if [ "${GOOS}" = "windows" ]; then
output="${output}.exe"
fi
echo "Building ${output}..."
GOOS="${GOOS}" GOARCH="${GOARCH}" go build -ldflags="${LDFLAGS}" -o "${output}" ${{ matrix.cmd }}
done
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.name }}
path: dist/*
retention-days: 1
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-binaries, build-ui]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: dist
merge-multiple: true
- name: Download admin UI artifact
uses: actions/download-artifact@v4
with:
name: admin-ui
path: dist
- name: Create checksums
run: |
cd dist
sha256sum * > checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
files: |
dist/*
draft: false
prerelease: ${{ contains(env.TAG_NAME, '-') }}
generate_release_notes: true
update-homebrew:
name: Update Homebrew Tap
runs-on: ubuntu-latest
needs: release
if: ${{ !contains(inputs.tag_name || github.ref_name, '-') }}
steps:
- name: Update wfctl formula in homebrew-tap
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.repo_dispatch_token }}
repository: GoCodeAlone/homebrew-tap
event-type: update-wfctl
client-payload: '{"version": "${{ env.TAG_NAME }}"}'
notify-ide-plugins:
name: Notify IDE Plugins
runs-on: ubuntu-latest
needs: release
if: ${{ !contains(inputs.tag_name || github.ref_name, '-') }}
strategy:
matrix:
repo: ['GoCodeAlone/workflow-editor']
steps:
- name: Trigger IDE update for ${{ matrix.repo }}
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.repo_dispatch_token }}
repository: ${{ matrix.repo }}
event-type: workflow-release
client-payload: '{"version": "${{ env.TAG_NAME }}"}'