ci: fix bundle on linux and macos #44
This file contains 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: build | |
on: push | |
permissions: | |
packages: write | |
contents: write | |
jobs: | |
build: | |
name: "Build Dungeondraft-GoPackager (${{ matrix.target.os }}, ${{ matrix.go-version }})" | |
runs-on: ${{ matrix.target.host || 'ubuntu-latest' }} | |
env: | |
GO111MODULE: on | |
strategy: | |
fail-fast: false | |
matrix: | |
go-version: ["1.23.x"] | |
target: | |
- os: linux | |
- os: windows | |
ext: .exe | |
host: windows-latest | |
- os: darwin | |
host: macos-latest | |
steps: | |
- name: Setup Go environment | |
id: setup-go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Force "autocrlf" | |
run: git config --global core.autocrlf input | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache build artifacts | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
~/.cache/fyne-cross | |
key: ${{ runner.os }}-build-cache-${{ hashFiles('**/go.sum') }} | |
- name: Setup msys2 | |
if: ${{ runner.os == 'Windows' }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: UCRT64 | |
install: >- | |
base-devel | |
mingw-w64-ucrt-x86_64-toolchain | |
mingw-w64-ucrt-x86_64-libwebp | |
mingw-w64-ucrt-x86_64-go | |
- name: Install Build Deps (Linux) | |
if: ${{ runner.os == 'Linux' }} | |
run: sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev libwebp-dev | |
- name: Install Build Deps (Macos) | |
if: ${{ runner.os == 'macOS' }} | |
run: brew install webp | |
- name: Install Fyne (windows) | |
if: ${{ runner.os == 'Windows' }} | |
shell: msys2 {0} | |
run: | | |
export GOROOT=/ucrt64/lib/go | |
export GOPATH=/ucrt64 | |
go install fyne.io/fyne/v2/cmd/fyne@latest | |
- name: Install Fyne | |
if: ${{ runner.os != 'Windows' }} | |
run: go install fyne.io/fyne/v2/cmd/fyne@latest | |
- name: install go deps (windows) | |
if: ${{ runner.os == 'Windows' }} | |
shell: msys2 {0} | |
run: | | |
export GOROOT=/ucrt64/lib/go | |
export GOPATH=/ucrt64 | |
go mod download | |
- name: install go deps | |
if: ${{ runner.os != 'Windows' }} | |
run: go mod download | |
- name: Build gui (windows) | |
if: ${{ runner.os == 'Windows' }} | |
shell: msys2 {0} | |
run: | | |
export GOROOT=/ucrt64/lib/go | |
export GOPATH=/ucrt64 | |
cp FyneApp.toml ./cmd/dungeondraft-packager | |
fyne package -src ./cmd/dungeondraft-packager --release -appID io.github.ryex.dungondraft-gopackager | |
- name: Build gui | |
if: ${{ runner.os != 'Windows' }} | |
run: | | |
cp FyneApp.toml ./cmd/dungeondraft-packager | |
fyne package -src ./cmd/dungeondraft-packager --release -appID io.github.ryex.dungondraft-gopackager | |
- name: Build cli (windows) | |
if: ${{ runner.os == 'Windows' }} | |
shell: msys2 {0} | |
run: | | |
export GOROOT=/ucrt64/lib/go | |
export GOPATH=/ucrt64 | |
go build -ldflags "-s -w" ./cmd/dungeondraft-packager-cli | |
- name: Build cli | |
if: ${{ runner.os != 'Windows' }} | |
run: | | |
go build -ldflags "-s -w" ./cmd/dungeondraft-packager-cli | |
- name: List dir | |
run: | | |
ls . | |
ls ./cmd/dungeondraft-packager | |
- name: Prep artifacts (windows) | |
if: ${{ runner.os == 'windows' }} | |
shell: msys2 {0} | |
run: | | |
mkdir install | |
cp "./cmd/dungeondraft-packager/Dungeondraft GoPackager.exe" ./install | |
cp "./dungeondraft-packager-cli.exe" ./install | |
cp *.md ./install | |
cp /ucrt64/bin/libwebp-*.dll ./install | |
cp /ucrt64/bin/libsharpyuv-*.dll ./install | |
ls -r ./install | |
ldd ./install/dungeondraft-packager.exe | |
- name: Prep artifacts (linux) | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
mkdir install | |
tar -xJf "./Dungeondraft GoPackager.tar.gz" ./install | |
cp ./dungeondraft-packager* ./install | |
cp *.md ./install | |
ls -r ./install | |
ldd ./install/usr/local/bin/dungeondraft-packager | |
- name: Prep artifacts (maOS) | |
if: ${{ runner.os != 'macOS' }} | |
run: | | |
mkdir install | |
cp -r "./Dungeondraft GoPackager.app" ./install | |
cp ./dungeondraft-packager* ./install | |
cp *.md ./install | |
ls -r ./install | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Dungeondraft-GoPackager-${{ runner.os }} | |
path: install/** | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: List dir | |
run: ls | |
- name: Package | |
run: | | |
pushd Dungeondraft-GoPackager-Linux ; tar -czf ../Dungeondraft-GoPackager-Linux.tgz * ; popd | |
pushd Dungeondraft-GoPackager-macOS ; zip -r ../Dungeondraft-GoPackager-macOS.zip * ; popd | |
pushd Dungeondraft-GoPackager-Windows ; zip -r ../Dungeondraft-GoPackager-Windows.zip * ; popd | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: Dungeondraft-GoPackager-Linux/CHANGELOG.md | |
draft: true | |
files: | | |
Dungeondraft-GoPackager-Linux.tar.gz | |
Dungeondraft-GoPackager-macOS.zip | |
Dungeondraft-GoPackager-Windows.zip |