Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

fix: add CGO_ENABLED=0 to CI workflow for static compilation #24

fix: add CGO_ENABLED=0 to CI workflow for static compilation

fix: add CGO_ENABLED=0 to CI workflow for static compilation #24

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
suffix: darwin-amd64
- goos: darwin
goarch: arm64
suffix: darwin-arm64
- goos: linux
goarch: amd64
suffix: linux-amd64
- goos: linux
goarch: arm64
suffix: linux-arm64
- goos: windows
goarch: amd64
suffix: windows-amd64.exe
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -ldflags "-s -w \
-X github.com/AlfonsSkills/SkillSync/cmd.Version=${{ steps.version.outputs.VERSION }} \
-X github.com/AlfonsSkills/SkillSync/cmd.GitCommit=${{ github.sha }} \
-X github.com/AlfonsSkills/SkillSync/cmd.BuildTime=$(date -u '+%Y-%m-%d_%H:%M:%S')" \
-o skillsync-${{ matrix.suffix }} .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: skillsync-${{ matrix.suffix }}
path: skillsync-${{ matrix.suffix }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Read changelog
id: changelog
run: |
VERSION=${{ steps.version.outputs.VERSION }}
CHANGELOG_FILE="changelog/${VERSION}.md"
if [ -f "$CHANGELOG_FILE" ]; then
# Read changelog content, skip the version header line
BODY=$(tail -n +3 "$CHANGELOG_FILE")
echo "CHANGELOG_FOUND=true" >> $GITHUB_OUTPUT
# Use multiline output
echo "BODY<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "CHANGELOG_FOUND=false" >> $GITHUB_OUTPUT
echo "⚠️ No changelog found for $VERSION"
fi
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
body: ${{ steps.changelog.outputs.BODY }}
generate_release_notes: ${{ steps.changelog.outputs.CHANGELOG_FOUND == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 自动更新 Homebrew Formula
- name: Update Homebrew Formula
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
# 计算各平台二进制文件的 SHA256
SHA_DARWIN_ARM64=$(shasum -a 256 dist/skillsync-darwin-arm64 | cut -d ' ' -f 1)
SHA_DARWIN_AMD64=$(shasum -a 256 dist/skillsync-darwin-amd64 | cut -d ' ' -f 1)
SHA_LINUX_ARM64=$(shasum -a 256 dist/skillsync-linux-arm64 | cut -d ' ' -f 1)
SHA_LINUX_AMD64=$(shasum -a 256 dist/skillsync-linux-amd64 | cut -d ' ' -f 1)
# 生成 Formula 文件
cat > skillsync.rb << EOF
class Skillsync < Formula
desc "Sync skills from Git repositories to 14+ AI coding tools"
homepage "https://github.com/AlfonsSkills/SkillSync"
version "${VERSION#v}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/AlfonsSkills/SkillSync/releases/download/${VERSION}/skillsync-darwin-arm64"
sha256 "${SHA_DARWIN_ARM64}"
else
url "https://github.com/AlfonsSkills/SkillSync/releases/download/${VERSION}/skillsync-darwin-amd64"
sha256 "${SHA_DARWIN_AMD64}"
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/AlfonsSkills/SkillSync/releases/download/${VERSION}/skillsync-linux-arm64"
sha256 "${SHA_LINUX_ARM64}"
else
url "https://github.com/AlfonsSkills/SkillSync/releases/download/${VERSION}/skillsync-linux-amd64"
sha256 "${SHA_LINUX_AMD64}"
end
end
def install
bin.install Dir["skillsync*"].first => "skillsync"
end
test do
system "#{bin}/skillsync", "--version"
end
end
EOF
# 克隆 homebrew-tap 仓库并更新
git clone https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/AlfonsSkills/homebrew-tap.git
mkdir -p homebrew-tap/Formula
mv skillsync.rb homebrew-tap/Formula/
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/skillsync.rb
git commit -m "Update skillsync to ${VERSION}"
git push