Skip to content

Switch GitHub workflow to macOS 14 #53

Switch GitHub workflow to macOS 14

Switch GitHub workflow to macOS 14 #53

Workflow file for this run

name: Build master binaries
on:
push:
branches: [ master ]
jobs:
build-linux:
name: Build (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create build directory
run: |
mkdir ./build
- name: Build in container
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3.0.0
with:
image: ubuntu:18.04
options: -v ${{ github.workspace }}:/workspace
run: |
cd /workspace
bash ./.github/workflows/build-master-linux.sh
- name: Zip
run: |
for folder in "$PWD"/build/*/; do
name="$(basename "$folder")"
cd "$folder"
zip -r "../$name.zip" ./*
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: linux
path: ./build/*.zip
build-windows:
name: Build (Windows)
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Download toolchain
run: |
$ToolchainVersion = "20240903"
$ToolchainSHA256 = "879ae28c8c38df8a18b5a152a1154ffb87860e6eedc5f8fbd2f66184ef21e3c8"
New-Item -ItemType Directory .\toolchain
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest "https://github.com/mstorsjo/llvm-mingw/releases/download/$ToolchainVersion/llvm-mingw-$ToolchainVersion-ucrt-x86_64.zip" -OutFile .\toolchain\llvm-mingw.zip
$actualSHA256 = Get-FileHash -Algorithm SHA256 .\toolchain\llvm-mingw.zip
if ($actualSHA256.Hash -ne $ToolchainSHA256) {
Write-Output "Toolchain checksum does not match!"
exit 1
}
Expand-Archive .\toolchain\llvm-mingw.zip .\toolchain
Move-Item ".\toolchain\llvm-mingw-$ToolchainVersion-ucrt-x86_64" .\toolchain\llvm-mingw
- name: Build CLI (x86-64)
env:
CGO_ENABLED: 0
GOARCH: amd64
run: |
go build -o .\build\x86-64\dsl.exe .\cmd
- name: Build CLI (x86)
env:
CGO_ENABLED: 0
GOARCH: 386
run: |
go build -o .\build\x86\dsl.exe .\cmd
- name: Build CLI (arm64)
env:
CGO_ENABLED: 0
GOARCH: arm64
run: |
go build -o .\build\arm64\dsl.exe .\cmd
- name: Build GUI (x86-64)
env:
CC: x86_64-w64-mingw32-clang
CXX: x86_64-w64-mingw32-clang++
CGO_ENABLED: 1
GOARCH: amd64
run: |
$Env:Path = "$PWD\toolchain\llvm-mingw\bin;$Env:Path"
go build -tags gui -ldflags="-H windowsgui" -o .\build\x86-64\dsl-gui.exe .\cmd
- name: Build GUI (x86)
env:
CC: i686-w64-mingw32-clang
CXX: i686-w64-mingw32-clang++
CGO_ENABLED: 1
GOARCH: 386
run: |
$Env:Path = "$PWD\toolchain\llvm-mingw\bin;$Env:Path"
go build -tags gui -ldflags="-H windowsgui" -o .\build\x86\dsl-gui.exe .\cmd
- name: Build GUI (arm64)
env:
CC: aarch64-w64-mingw32-clang
CXX: aarch64-w64-mingw32-clang++
CGO_ENABLED: 1
GOARCH: arm64
run: |
$Env:Path = "$PWD\toolchain\llvm-mingw\bin;$Env:Path"
go build -tags gui -ldflags="-H windowsgui" -o .\build\arm64\dsl-gui.exe .\cmd
- name: Zip
run: |
foreach ($folder in $(Get-ChildItem -Directory .\build)) {
Set-Location $folder.FullName
Compress-Archive .\* "..\$($folder.Name).zip"
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows
path: ./build/*.zip
build-macos:
name: Build (macOS)
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Build CLI
env:
CGO_ENABLED: 0
run: |
GOARCH=amd64 go build -o ./build/universal/dsl-x86-64 ./cmd
GOARCH=arm64 go build -o ./build/universal/dsl-arm64 ./cmd
lipo -create -output ./build/universal/dsl ./build/universal/dsl-x86-64 ./build/universal/dsl-arm64
rm ./build/universal/dsl-x86-64 ./build/universal/dsl-arm64
- name: Build GUI
env:
CGO_ENABLED: 1
run: |
mkdir -p ./build/universal/dsl-gui.app/Contents/MacOS
cat << EOF > ./build/universal/dsl-gui.app/Contents/Info.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>dsl-gui</string>
<key>CFBundleIdentifier</key>
<string>eu.3e8.go.dsl</string>
</dict>
</plist>
EOF
GOARCH=amd64 MACOSX_DEPLOYMENT_TARGET=10.15 \
go build -tags gui -o ./build/universal/dsl-gui-x86-64 ./cmd
GOARCH=arm64 MACOSX_DEPLOYMENT_TARGET=11.0 \
go build -tags gui -o ./build/universal/dsl-gui-arm64 ./cmd
lipo -create -output ./build/universal/dsl-gui.app/Contents/MacOS/dsl-gui \
./build/universal/dsl-gui-x86-64 ./build/universal/dsl-gui-arm64
rm ./build/universal/dsl-gui-x86-64 ./build/universal/dsl-gui-arm64
- name: Zip
run: |
for folder in "$PWD"/build/*/; do
name="$(basename "$folder")"
cd "$folder"
zip -r "../$name.zip" ./*
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: macos
path: ./build/*.zip
release:
name: Package and release
runs-on: ubuntu-latest
needs:
- build-linux
- build-windows
- build-macos
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Determine variables
id: vars
shell: bash
env:
TZ: UTC0
run: |
echo "version=$(git log -1 --format='%cd+%h' --date='format-local:%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "time=$(git log -1 --format='%cd' --date='format-local:%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
- name: Prepare common files
run: |
mkdir -p ./build/template
echo "${{ steps.vars.outputs.version }}" > ./build/template/VERSION
cp LICENSE ./build/template/
cp ./cmd/LICENSE-3RD-PARTY ./build/template/
cp README.md ./build/template/
mkdir ./build/template/docs
cp ./docs/*.md ./build/template/docs/
- name: Install pandoc
run: |
sudo apt update
sudo apt install -y pandoc
- name: Build HTML documentation
run: |
./docs/build.sh ./build/template
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Build archives
shell: bash
run: |
cd ./build
for artifact in ../artifacts/*/*.zip; do
target="$(basename "$(dirname "$artifact")")"
arch="$(basename -s ".zip" "$artifact")"
name="dsl_${{ steps.vars.outputs.version }}_${target}_${arch}"
cp -r ./template "./$name"
unzip "../artifacts/$target/$arch.zip" -d "./$name/"
zip -r "$name.zip" "$name"
done
- name: Create release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: github-master-builds
prerelease: true
allowUpdates: true
removeArtifacts: true
artifacts: "./build/*.zip"
artifactContentType: application/zip
name: Auto-built binaries
body: |
These binaries are automatically built from the master branch.\
Current version: ${{ github.sha }} (${{ steps.vars.outputs.time }})
Select the build for your platform from the assets below.
*Note: If you want to get the corresponding source code please use Git.\
The source archives linked below don't contain the actual source.*