Merge pull request #935 from fudiwei/dev #210
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "v[0-9]*" | |
jobs: | |
prepare-ui: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.11.0 | |
- name: Build UI | |
run: | | |
echo "VITE_APP_VERSION=${GITHUB_REF#refs/tags/}" > ./ui/.env | |
npm --prefix=./ui ci | |
npm --prefix=./ui run build | |
- name: Upload UI build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ui-build | |
path: ./ui/dist | |
retention-days: 1 | |
build-linux: | |
needs: prepare-ui | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Download UI build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ui-build | |
path: ./ui/dist | |
- name: Build Linux binaries | |
env: | |
CGO_ENABLED: 0 | |
GOOS: linux | |
run: | | |
mkdir -p dist/linux | |
for ARCH in amd64 arm64 armv7; do | |
if [ "$ARCH" == "armv7" ]; then | |
go env -w GOARCH=arm | |
go env -w GOARM=7 | |
else | |
go env -w GOARCH=$ARCH | |
go env -u GOARM | |
fi | |
go build -ldflags="-s -w -X github.com/certimate-go/certimate.Version=${GITHUB_REF#refs/tags/}" -o dist/linux/certimate_${GITHUB_REF#refs/tags/}_linux_$ARCH | |
done | |
- name: Upload Linux binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-binaries | |
path: dist/linux/ | |
retention-days: 1 | |
build-macos: | |
needs: prepare-ui | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Download UI build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ui-build | |
path: ./ui/dist | |
- name: Build macOS binaries | |
env: | |
CGO_ENABLED: 0 | |
GOOS: darwin | |
run: | | |
mkdir -p dist/darwin | |
for ARCH in amd64 arm64; do | |
go env -w GOARCH=$ARCH | |
go build -ldflags="-s -w -X github.com/certimate-go/certimate.Version=${GITHUB_REF#refs/tags/}" -o dist/darwin/certimate_${GITHUB_REF#refs/tags/}_darwin_$ARCH | |
done | |
- name: Upload macOS binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macos-binaries | |
path: dist/darwin/ | |
retention-days: 1 | |
build-windows: | |
needs: prepare-ui | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: "go.mod" | |
- name: Download UI build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ui-build | |
path: ./ui/dist | |
- name: Build Windows binaries | |
env: | |
CGO_ENABLED: 0 | |
GOOS: windows | |
run: | | |
mkdir -p dist/windows | |
for ARCH in amd64 arm64 386; do | |
go env -w GOARCH=$ARCH | |
go build -ldflags="-s -w -X github.com/certimate-go/certimate.Version=${GITHUB_REF#refs/tags/}" -o dist/windows/certimate_${GITHUB_REF#refs/tags/}_windows_$ARCH.exe | |
done | |
- name: Upload Windows binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-binaries | |
path: dist/windows/ | |
retention-days: 1 | |
create-release: | |
needs: [build-linux, build-macos, build-windows] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download all binaries | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
- name: Prepare release assets | |
run: | | |
mkdir -p dist | |
cp -r artifacts/linux-binaries/* dist/ | |
cp -r artifacts/macos-binaries/* dist/ | |
cp -r artifacts/windows-binaries/* dist/ | |
find dist -type f -not -name "*.exe" -exec chmod +x {} \; | |
cd dist | |
for bin in certimate_*; do | |
if [[ "$bin" == *".exe" ]]; then | |
entrypoint="certimate.exe" | |
else | |
entrypoint="certimate" | |
fi | |
tmpdir=$(mktemp -d) | |
cp "$bin" "${tmpdir}/${entrypoint}" | |
cp ../LICENSE "$tmpdir/LICENSE" | |
cp ../README.md "$tmpdir/README_zhCN.md" | |
cp ../README_EN.md "$tmpdir/README_enUS.md" | |
cp ../CHANGELOG.md "$tmpdir/CHANGELOG.md" | |
sed -i 's/README_EN\.md/README_enUS.md/g' "$tmpdir/README_zhCN.md" | |
sed -i 's/README\.md/README_zhCN.md/g' "$tmpdir/README_enUS.md" | |
if [[ "$bin" == *".exe" ]]; then | |
zip -j "${bin%.exe}.zip" "$tmpdir"/* | |
else | |
zip -j -X "${bin}.zip" "$tmpdir"/* | |
fi | |
rm -rf "$tmpdir" | |
done | |
sha256sum *.zip > checksums.txt | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
dist/*.zip | |
dist/checksums.txt | |
draft: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |