Skip to content

feat: 快捷启动按钮优化 #103

feat: 快捷启动按钮优化

feat: 快捷启动按钮优化 #103

Workflow file for this run

name: Build
on:
push:
branches: [ master, main, develop ]
tags:
- 'v*'
pull_request:
branches: [ master, main ]
workflow_dispatch:
jobs:
build:
name: Build for ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux
- os: ubuntu-latest
platform: linux-amd64
goos: linux
goarch: amd64
artifact_name: CodeKanban-linux-amd64
exe_name: CodeKanban
- os: ubuntu-latest
platform: linux-arm64
goos: linux
goarch: arm64
artifact_name: CodeKanban-linux-arm64
exe_name: CodeKanban
# Windows
- os: windows-latest
platform: windows-amd64
goos: windows
goarch: amd64
artifact_name: CodeKanban-windows-amd64
exe_name: CodeKanban.exe
# macOS
- os: macos-latest
platform: darwin-amd64
goos: darwin
goarch: amd64
artifact_name: CodeKanban-macos-amd64
exe_name: CodeKanban
- os: macos-latest
platform: darwin-arm64
goos: darwin
goarch: arm64
artifact_name: CodeKanban-macos-arm64
exe_name: CodeKanban
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24.6'
cache: true
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'ui/pnpm-lock.yaml'
- name: Install frontend dependencies
working-directory: ./ui
run: pnpm install
- name: Build frontend
working-directory: ./ui
run: pnpm build
- name: Copy frontend dist to static
shell: bash
run: |
rm -rf static/*
cp -r ui/dist/* static/
- name: Extract version info
id: version
shell: bash
run: |
BUILD_DATE=$(date +%Y%m%d)
echo "BUILD_METADATA=+${BUILD_DATE}" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
# Tag build (stable release)
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
echo "VERSION_MAIN=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "VERSION_PRERELEASE=" >> $GITHUB_OUTPUT
echo "APP_CHANNEL=stable" >> $GITHUB_OUTPUT
else
# Commit build (development)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
TAG_VERSION="${LATEST_TAG#v}"
echo "VERSION_MAIN=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "VERSION_PRERELEASE=-alpha" >> $GITHUB_OUTPUT
echo "APP_CHANNEL=dev" >> $GITHUB_OUTPUT
fi
- name: Build Go binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -ldflags="-s -w -X 'main.VERSION_MAIN=${{ steps.version.outputs.VERSION_MAIN }}' -X 'main.VERSION_PRERELEASE=${{ steps.version.outputs.VERSION_PRERELEASE }}' -X 'main.VERSION_BUILD_METADATA=${{ steps.version.outputs.BUILD_METADATA }}' -X 'main.APP_CHANNEL=${{ steps.version.outputs.APP_CHANNEL }}'" -trimpath -o ${{ matrix.exe_name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.exe_name }}
retention-days: 30
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
CURRENT_TAG="${GITHUB_REF#refs/tags/}"
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${CURRENT_TAG}^ 2>/dev/null || echo "")
echo "Current tag: ${CURRENT_TAG}"
echo "Previous tag: ${PREVIOUS_TAG}"
{
echo "CHANGELOG<<EOF"
echo "## What's Changed"
echo ""
if [ -n "${PREVIOUS_TAG}" ]; then
# Get commits between previous tag and current tag
git log ${PREVIOUS_TAG}..${CURRENT_TAG} --pretty=format:"- %s (%h)" --no-merges
else
# First release, get all commits
git log ${CURRENT_TAG} --pretty=format:"- %s (%h)" --no-merges | head -20
fi
echo ""
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${CURRENT_TAG}"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Package binaries
run: |
mkdir -p release
# Package Windows binaries as .zip
cd artifacts/CodeKanban-windows-amd64
zip ../../release/CodeKanban-windows-amd64.zip CodeKanban.exe
cd ../..
# Package Linux binaries as .tar.gz
cd artifacts/CodeKanban-linux-amd64
tar -czf ../../release/CodeKanban-linux-amd64.tar.gz CodeKanban
cd ../..
cd artifacts/CodeKanban-linux-arm64
tar -czf ../../release/CodeKanban-linux-arm64.tar.gz CodeKanban
cd ../..
# Package macOS binaries as .tar.gz
cd artifacts/CodeKanban-macos-amd64
tar -czf ../../release/CodeKanban-macos-amd64.tar.gz CodeKanban
cd ../..
cd artifacts/CodeKanban-macos-arm64
tar -czf ../../release/CodeKanban-macos-arm64.tar.gz CodeKanban
cd ../..
# List packaged files
ls -lh release/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
body: ${{ steps.changelog.outputs.CHANGELOG }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}