build fat binary on macOS #294
Workflow file for this run
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: Go | |
on: [push] | |
jobs: | |
Build: | |
strategy: | |
matrix: | |
lua-version: [lua51, lua52, lua53, lua54] | |
os: [macos, ubuntu, windows] | |
runs-on: ${{ matrix.os }}-latest | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.21 | |
id: go | |
- uses: msys2/setup-msys2@v2 | |
if: matrix.os == 'windows' | |
with: | |
update: true | |
msystem: MINGW64 | |
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-make | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Build on Unix | |
if: matrix.os != 'windows' | |
run: | | |
cd golua/lua | |
./buildlua.sh | |
cd - | |
- name: Build on Unix | |
if: matrix.os != 'macos' && matrix.os != 'windows' | |
run: | | |
go build -ldflags="-s -w" -tags ${{ matrix.lua-version }} -o getnovel . | |
mkdir ${{ matrix.os }}-amd64 | |
cp getnovel ${{ matrix.os }}-amd64/ | |
cp -r pdfpresets ${{ matrix.os }}-amd64/ | |
cp -r handlers ${{ matrix.os }}-amd64/ | |
cp -r lua ${{ matrix.os }}-amd64/ | |
- name: Build on macOS | |
if: matrix.os == 'macos' | |
run: | | |
env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -tags ${{ matrix.lua-version }} -o getnovel-amd64 . | |
env CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -tags ${{ matrix.lua-version }} -o getnovel-arm64 . | |
lipo -create -output getnovel getnovel-amd64 getnovel-arm64 | |
mkdir ${{ matrix.os }}-amd64 | |
cp getnovel ${{ matrix.os }}-amd64/ | |
cp -r pdfpresets ${{ matrix.os }}-amd64/ | |
cp -r handlers ${{ matrix.os }}-amd64/ | |
cp -r lua ${{ matrix.os }}-amd64/ | |
- name: Build Lua on Windows | |
if: matrix.os == 'windows' | |
shell: msys2 {0} | |
run: | | |
cd golua/lua/${{ matrix.lua-version }} | |
env MSYSTEM=MINGW64 PATH=$PATH:/mingw64/bin mingw32-make mingw | |
cd - | |
- name: Build GetNovel on Windows | |
if: matrix.os == 'windows' | |
shell: cmd | |
run: | | |
set PATH=D:\a\_temp\msys64\mingw64\bin;%PATH% | |
go build -ldflags="-s -w" -tags ${{ matrix.lua-version }} -o getnovel.exe . | |
- name: copy files on Windows | |
if: matrix.os == 'windows' | |
shell: msys2 {0} | |
run: | | |
mkdir ${{ matrix.os }}-amd64 | |
cp getnovel.exe ${{ matrix.os }}-amd64/ | |
cp -r pdfpresets ${{ matrix.os }}-amd64/ | |
cp -r handlers ${{ matrix.os }}-amd64/ | |
cp -r lua ${{ matrix.os }}-amd64/ | |
- name: Upload artifact getnovel-${{ matrix.os }}-amd64 | |
uses: actions/[email protected] | |
with: | |
name: getnovel-${{ matrix.os }}-${{ matrix.lua-version }} | |
path: ${{ matrix.os }}-amd64 | |
- name: upload getnovel Release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GH_TOKEN }} | |
file: ${{ matrix.os }}-amd64 | |
asset_name: getnovel-${{ matrix.os }}-${{ matrix.lua-version }} | |
tag: ${{ github.ref }} | |
release_name: ${{ github.ref_name }} | |
overwrite: true |