Skip to content

fix(build): use !windows build tag for stderr redirect #45

fix(build): use !windows build tag for stderr redirect

fix(build): use !windows build tag for stderr redirect #45

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Init build-required submodules
run: git submodule update --init --depth 1 refs/amneziawg-go refs/tailscale-wf
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ui/frontend/package-lock.json
- name: Extract version from tag
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
# Strip pre-release suffix for NSIS (requires X.X.X numeric format).
NSIS_VERSION="${VERSION%%-*}"
COMMIT="$(git rev-parse --short HEAD)"
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "NSIS_VERSION=$NSIS_VERSION" >> $GITHUB_ENV
echo "COMMIT=$COMMIT" >> $GITHUB_ENV
echo "BUILD_DATE=$DATE" >> $GITHUB_ENV
echo "LDFLAGS=-s -w -X main.version=$VERSION -X main.commit=$COMMIT -X main.buildDate=$DATE" >> $GITHUB_ENV
- name: Install tools
shell: bash
run: |
go install github.com/akavel/rsrc@latest
go install github.com/wailsapp/wails/v3/cmd/wails3@latest
choco install nsis -y --no-progress
- name: Install frontend dependencies
working-directory: ui/frontend
run: npm ci
- name: Generate Wails bindings
working-directory: ui
run: wails3 generate bindings
- name: Build frontend
working-directory: ui/frontend
run: npm run build
- name: Generate Windows resources (.syso)
shell: bash
run: |
ICO="ui/build/windows/icon.ico"
rsrc -manifest cmd/awg-split-tunnel/app.manifest -ico "$ICO" -o cmd/awg-split-tunnel/rsrc_windows_amd64.syso
rsrc -manifest ui/build/windows/wails.exe.manifest -ico "$ICO" -o ui/rsrc_windows_amd64.syso
rsrc -manifest cmd/awg-split-tunnel-updater/app.manifest -ico "$ICO" -o cmd/awg-split-tunnel-updater/rsrc_windows_amd64.syso
rsrc -manifest cmd/awg-diag/app.manifest -ico "$ICO" -o cmd/awg-diag/rsrc_windows_amd64.syso
- name: Download wintun.dll
shell: bash
run: |
curl -fsSL https://www.wintun.net/builds/wintun-0.14.1.zip -o wintun.zip
unzip -j wintun.zip "wintun/bin/amd64/wintun.dll" -d dll/
rm wintun.zip
- name: Build Go binaries
shell: bash
run: |
mkdir -p build
go build -ldflags "$LDFLAGS" -o build/awg-split-tunnel.exe ./cmd/awg-split-tunnel/
go build -ldflags "$LDFLAGS -H windowsgui" -o build/awg-split-tunnel-ui.exe ./ui/
go build -ldflags "$LDFLAGS" -o build/awg-split-tunnel-updater.exe ./cmd/awg-split-tunnel-updater/
go build -ldflags "$LDFLAGS" -o build/awg-split-tunnel-diag.exe ./cmd/awg-diag/
cp dll/wintun.dll build/
- name: Download WebView2 bootstrapper
shell: bash
run: |
curl -fsSL "https://go.microsoft.com/fwlink/p/?LinkId=2124703" \
-o ui/build/windows/nsis/MicrosoftEdgeWebview2Setup.exe
- name: Build NSIS installer
shell: bash
run: |
ABS_SERVICE="$(cygpath -w "$(pwd)/build/awg-split-tunnel.exe")"
ABS_GUI="$(cygpath -w "$(pwd)/build/awg-split-tunnel-ui.exe")"
ABS_UPDATER="$(cygpath -w "$(pwd)/build/awg-split-tunnel-updater.exe")"
ABS_WINTUN="$(cygpath -w "$(pwd)/build/wintun.dll")"
ABS_CONFIG="$(cygpath -w "$(pwd)/config.example.yaml")"
"/c/Program Files (x86)/NSIS/makensis.exe" \
-DARG_WAILS_AMD64_BINARY="$ABS_GUI" \
-DARG_SERVICE_BINARY="$ABS_SERVICE" \
-DARG_UPDATER_BINARY="$ABS_UPDATER" \
-DARG_WINTUN_DLL="$ABS_WINTUN" \
-DARG_CONFIG_EXAMPLE="$ABS_CONFIG" \
-DINFO_PRODUCTVERSION="$NSIS_VERSION" \
ui/build/windows/nsis/project.nsi
- name: Create release ZIP
shell: pwsh
run: |
Compress-Archive -Path `
build/awg-split-tunnel.exe, `
build/awg-split-tunnel-ui.exe, `
build/awg-split-tunnel-updater.exe, `
build/wintun.dll, `
config.example.yaml `
-DestinationPath "build/awg-split-tunnel-v${{ env.VERSION }}-windows-amd64.zip"
- uses: actions/upload-artifact@v4
with:
name: windows-artifacts
path: |
build/awg-split-tunnel-v*-windows-amd64.zip
build/*installer*.exe
retention-days: 5
build-macos:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Init build-required submodules
run: git submodule update --init --depth 1 refs/amneziawg-go refs/tailscale-wf
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Extract version
run: |
VERSION="${GITHUB_REF_NAME#v}"
COMMIT="$(git rev-parse --short HEAD)"
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "COMMIT=$COMMIT" >> $GITHUB_ENV
echo "BUILD_DATE=$DATE" >> $GITHUB_ENV
echo "LDFLAGS=-s -w -X main.version=$VERSION -X main.commit=$COMMIT -X main.buildDate=$DATE" >> $GITHUB_ENV
- name: Build daemon binaries
run: |
mkdir -p build
# arm64 (native on macos-14 runner)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 \
go build -ldflags "$LDFLAGS" -o build/awg-split-tunnel-arm64 ./cmd/awg-split-tunnel/
# amd64 (cross-compile)
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 \
go build -ldflags "$LDFLAGS" -o build/awg-split-tunnel-amd64 ./cmd/awg-split-tunnel/
# Universal binary
lipo -create -output build/awg-split-tunnel \
build/awg-split-tunnel-arm64 build/awg-split-tunnel-amd64
- name: Stage release files
run: |
mkdir -p build/stage
cp scripts/install-daemon.sh scripts/uninstall-daemon.sh build/stage/
cp config.example.yaml build/stage/
- name: Create tarballs
run: |
cd build
for ARCH in arm64 amd64; do
cp "awg-split-tunnel-${ARCH}" stage/awg-split-tunnel
tar czf "awg-split-tunnel-v${VERSION}-darwin-${ARCH}.tar.gz" \
-C stage awg-split-tunnel install-daemon.sh uninstall-daemon.sh config.example.yaml
rm stage/awg-split-tunnel
done
cp awg-split-tunnel stage/awg-split-tunnel
tar czf "awg-split-tunnel-v${VERSION}-darwin-universal.tar.gz" \
-C stage awg-split-tunnel install-daemon.sh uninstall-daemon.sh config.example.yaml
- uses: actions/upload-artifact@v4
with:
name: macos-daemon-artifacts
path: build/awg-split-tunnel-v*-darwin-*.tar.gz
retention-days: 5
build-macos-gui:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Init build-required submodules
run: git submodule update --init --depth 1 refs/amneziawg-go refs/tailscale-wf
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ui/frontend/package-lock.json
- name: Extract version
run: |
VERSION="${GITHUB_REF_NAME#v}"
COMMIT="$(git rev-parse --short HEAD)"
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "LDFLAGS=-s -w -X main.version=$VERSION -X main.commit=$COMMIT -X main.buildDate=$DATE" >> $GITHUB_ENV
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v3/cmd/wails3@latest
- name: Install frontend dependencies
working-directory: ui/frontend
run: npm ci
- name: Generate Wails bindings
working-directory: ui
run: wails3 generate bindings
- name: Build frontend
working-directory: ui/frontend
run: npm run build
- name: Generate icons
working-directory: ui/build
run: wails3 generate icons -input appicon.png -macfilename darwin/icons.icns -windowsfilename windows/icon.ico || true
- name: Build GUI binaries (CGO required for WKWebView)
working-directory: ui
run: |
mkdir -p bin
BUILD_FLAGS="-tags production -trimpath -buildvcs=false -ldflags=\"$LDFLAGS\""
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 \
go build -tags production -trimpath -buildvcs=false -ldflags "$LDFLAGS" \
-o bin/awg-split-tunnel-gui-arm64 .
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 \
go build -tags production -trimpath -buildvcs=false -ldflags "$LDFLAGS" \
-o bin/awg-split-tunnel-gui-amd64 .
lipo -create -output bin/awg-split-tunnel-gui \
bin/awg-split-tunnel-gui-arm64 bin/awg-split-tunnel-gui-amd64
- name: Create .app bundle
working-directory: ui
run: |
APP="bin/AWG Split Tunnel.app"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS"
mkdir -p "$APP/Contents/Resources"
cp bin/awg-split-tunnel-gui "$APP/Contents/MacOS/AWG Split Tunnel"
cp build/darwin/icons.icns "$APP/Contents/Resources/appicon.icns" 2>/dev/null || true
cat > "$APP/Contents/Info.plist" << 'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>AWG Split Tunnel</string>
<key>CFBundleIconFile</key>
<string>appicon</string>
<key>CFBundleIdentifier</key>
<string>com.awg.split-tunnel.gui</string>
<key>CFBundleName</key>
<string>AWG Split Tunnel</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION}</string>
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
PLIST
- name: Create DMG
working-directory: ui
run: |
hdiutil create -volname "AWG Split Tunnel" \
-srcfolder "bin/AWG Split Tunnel.app" \
-ov -format UDZO \
"bin/AWG-Split-Tunnel-v${VERSION}-darwin-universal.dmg"
- uses: actions/upload-artifact@v4
with:
name: macos-gui-artifacts
path: ui/bin/AWG-Split-Tunnel-v*-darwin-*.dmg
retention-days: 5
create-release:
needs: [build-windows, build-macos, build-macos-gui]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate changelog
shell: bash
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
TAG="${GITHUB_REF_NAME}"
if [ -n "$PREV_TAG" ]; then
RANGE="${PREV_TAG}..HEAD"
else
RANGE="HEAD"
fi
echo "# Changelog - ${TAG}" > CHANGELOG.md
echo "" >> CHANGELOG.md
# Process each conventional commit type
for PAIR in "feat:Features" "fix:Bug Fixes" "perf:Performance" "refactor:Refactoring" "docs:Documentation" "test:Tests" "ci:CI" "build:Build"; do
TYPE="${PAIR%%:*}"
LABEL="${PAIR#*:}"
COMMITS=$(git log $RANGE --oneline --no-merges --grep="^${TYPE}" --format="- %s (%h)" 2>/dev/null || true)
if [ -n "$COMMITS" ]; then
echo "## $LABEL" >> CHANGELOG.md
echo "$COMMITS" >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
done
# Other commits (not matching any type)
OTHER=$(git log $RANGE --oneline --no-merges \
--invert-grep --grep="^feat" --grep="^fix" --grep="^perf" \
--grep="^refactor" --grep="^docs" --grep="^test" --grep="^ci" \
--grep="^build" --format="- %s (%h)" 2>/dev/null || true)
if [ -n "$OTHER" ]; then
echo "## Other" >> CHANGELOG.md
echo "$OTHER" >> CHANGELOG.md
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ github.ref_name }}" \
--title "Release ${{ github.ref_name }}" \
--notes-file CHANGELOG.md \
artifacts/*