Skip to content

Commit e7f0586

Browse files
committed
add build workflow
1 parent ede926c commit e7f0586

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
name: Build and Release
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
include:
18+
- os: linux
19+
arch: amd64
20+
goos: linux
21+
goarch: amd64
22+
- os: windows
23+
arch: amd64
24+
goos: windows
25+
goarch: amd64
26+
- os: macOS-amd64
27+
arch: amd64
28+
goos: darwin
29+
goarch: amd64
30+
- os: macOS-arm64
31+
arch: arm64
32+
goos: darwin
33+
goarch: arm64
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Set up Go
40+
uses: actions/setup-go@v5
41+
with:
42+
go-version: '1.25'
43+
44+
- name: Build Binaries
45+
shell: bash
46+
run: |
47+
VERSION=${GITHUB_REF_NAME}
48+
FOLDER_NAME="flow-driver-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}"
49+
mkdir -p $FOLDER_NAME
50+
51+
SUFFIX=""
52+
if [ "${{ matrix.goos }}" == "windows" ]; then
53+
SUFFIX=".exe"
54+
fi
55+
56+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o $FOLDER_NAME/client$SUFFIX ./cmd/client
57+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o $FOLDER_NAME/server$SUFFIX ./cmd/server
58+
59+
cp client_config.json.example $FOLDER_NAME/
60+
cp server_config.json.example $FOLDER_NAME/
61+
cp README.md $FOLDER_NAME/
62+
63+
zip -r "${FOLDER_NAME}.zip" $FOLDER_NAME
64+
65+
- name: Release
66+
uses: softprops/action-gh-release@v1
67+
with:
68+
files: flow-driver-*.zip
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/build_release.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
set -e
3+
4+
VERSION="v1.0.0"
5+
RELEASE_DIR="release"
6+
7+
# Clean previous releases
8+
rm -rf "$RELEASE_DIR"
9+
mkdir -p "$RELEASE_DIR"
10+
11+
platforms=(
12+
"linux/amd64"
13+
"windows/amd64"
14+
"darwin/amd64"
15+
"darwin/arm64"
16+
)
17+
18+
echo "Building binaries for version $VERSION..."
19+
20+
for platform in "${platforms[@]}"; do
21+
OS=${platform%/*}
22+
ARCH=${platform#*/}
23+
24+
SUFFIX=""
25+
if [ "$OS" == "windows" ]; then
26+
SUFFIX=".exe"
27+
fi
28+
29+
FOLDER_NAME="flow-driver-${VERSION}-${OS}-${ARCH}"
30+
OUTPUT_PATH="$RELEASE_DIR/$FOLDER_NAME"
31+
mkdir -p "$OUTPUT_PATH"
32+
33+
echo "Building $OS/$ARCH..."
34+
35+
# Build Client
36+
CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH /opt/homebrew/bin/go build -o "$OUTPUT_PATH/client$SUFFIX" ./cmd/client
37+
38+
# Build Server
39+
CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH /opt/homebrew/bin/go build -o "$OUTPUT_PATH/server$SUFFIX" ./cmd/server
40+
41+
# Copy Example Configs and README
42+
cp client_config.json.example "$OUTPUT_PATH/"
43+
cp server_config.json.example "$OUTPUT_PATH/"
44+
cp README.md "$OUTPUT_PATH/"
45+
46+
# Zip it up
47+
(cd "$RELEASE_DIR" && zip -r "${FOLDER_NAME}.zip" "$FOLDER_NAME")
48+
49+
# Cleanup folder (keep only zip)
50+
rm -rf "$OUTPUT_PATH"
51+
done
52+
53+
echo "Done! Release packages created in $RELEASE_DIR/:"
54+
ls -lh "$RELEASE_DIR"

0 commit comments

Comments
 (0)