diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5808b1a2..34675ca3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,10 +73,10 @@ jobs: sudo apt-get install --no-install-recommends $LINUX_DEPENDENCIES - platform: darwin runs-on: macos-12 - build: ./hack/build-app.sh - - platform: windows-amd64 + build: ./hack/build-macos.sh + - platform: windows runs-on: windows-latest - extension: .exe + build: ./hack/build-windows.sh steps: - name: Checkout uses: actions/checkout@v4 @@ -115,7 +115,7 @@ jobs: - name: Build (Default) if: ${{ !matrix.build }} run: | - go build -ldflags='-w -s' -trimpath -o dist/gones${{ matrix.extension }} + go build -ldflags='-w -s' -trimpath -o dist/gones env: CGO_ENABLED: "1" - name: Compress @@ -180,7 +180,7 @@ jobs: -v "$(go env GOMODCACHE):/go/pkg/mod" \ -v "$PWD:/app" \ builder \ - go build -ldflags='-w -s' -trimpath -o dist/gones${{ matrix.extension }} + go build -ldflags='-w -s' -trimpath -o dist/gones - name: Compress run: tar -cvf gones.tar -C dist . - name: Upload Artifact diff --git a/.gitignore b/.gitignore index fd9a4d20..46976722 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /gones gones.wasm wasm_exec.js +*.syso diff --git a/assets/.gitignore b/assets/.gitignore index 99f56c91..fa4b31c4 100644 --- a/assets/.gitignore +++ b/assets/.gitignore @@ -1,2 +1,3 @@ *.icns GoNES.iconset/ +winres/*.png diff --git a/assets/png/icon_48x48.png b/assets/png/icon_48x48.png new file mode 100644 index 00000000..c9b4f715 Binary files /dev/null and b/assets/png/icon_48x48.png differ diff --git a/assets/winres/winres.json b/assets/winres/winres.json new file mode 100644 index 00000000..d182ce93 --- /dev/null +++ b/assets/winres/winres.json @@ -0,0 +1,65 @@ +{ + "RT_GROUP_ICON": { + "APP": { + "0000": [ + "icon16.png", + "icon32.png", + "icon48.png", + "icon64.png", + "icon128.png", + "icon256.png" + ] + } + }, + "RT_MANIFEST": { + "#1": { + "0409": { + "identity": { + "name": "GoNES", + "version": "" + }, + "description": "NES emulator written in Go", + "minimum-os": "win7", + "execution-level": "as invoker", + "ui-access": false, + "auto-elevate": false, + "dpi-awareness": "system", + "disable-theming": false, + "disable-window-filtering": false, + "high-resolution-scrolling-aware": false, + "ultra-high-resolution-scrolling-aware": false, + "long-path-aware": false, + "printer-driver-isolation": false, + "gdi-scaling": false, + "segment-heap": false, + "use-common-controls-v6": false + } + } + }, + "RT_VERSION": { + "#1": { + "0000": { + "fixed": { + "file_version": "0.0.0.0", + "product_version": "0.0.0.0" + }, + "info": { + "0409": { + "Comments": "", + "CompanyName": "gabe565", + "FileDescription": "NES emulator written in Go", + "FileVersion": "", + "InternalName": "", + "LegalCopyright": "", + "LegalTrademarks": "", + "OriginalFilename": "", + "PrivateBuild": "", + "ProductName": "GoNES", + "ProductVersion": "", + "SpecialBuild": "" + } + } + } + } + } +} diff --git a/hack/build-app.sh b/hack/build-macos.sh similarity index 97% rename from hack/build-app.sh rename to hack/build-macos.sh index 1da5802c..de14274f 100755 --- a/hack/build-app.sh +++ b/hack/build-macos.sh @@ -7,7 +7,7 @@ set -euo pipefail cd "$(git rev-parse --show-toplevel)" -rm -rf dist assets/GoNES.iconset +rm -rf dist/*.app assets/GoNES.iconset mkdir -p dist # Generate icns diff --git a/hack/build-windows.sh b/hack/build-windows.sh new file mode 100755 index 00000000..1eda7e82 --- /dev/null +++ b/hack/build-windows.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +BINARY_NAME='GoNES' + +set -euo pipefail + +cd "$(git rev-parse --show-toplevel)" + +rm -rf -- dist/*.exe assets/winres/*.png *.syso +mkdir -p dist + +command -v go-winres &>/dev/null || go install github.com/tc-hib/go-winres@latest + +# Generate metadata +cp -a assets/{png/icon_16x16,winres/icon16}.png +cp -a assets/{png/icon_32x32,winres/icon32}.png +cp -a assets/{png/icon_48x48,winres/icon48}.png +cp -a assets/{png/icon_64x64,winres/icon64}.png +cp -a assets/{png/icon_128x128,winres/icon128}.png +cp -a assets/{png/icon_256x256,winres/icon256}.png +go-winres make --arch=amd64,arm64 --in=assets/winres/winres.json + +# Build binary +export GOOS=windows CGO_ENABLED=1 +for ARCH in amd64 arm64; do + echo Build "$BINARY_NAME-$ARCH.exe" + GOARCH="$ARCH" go build -ldflags='-w -s' -trimpath -o "dist/$BINARY_NAME-$ARCH.exe" "$(git rev-parse --show-toplevel)" +done diff --git a/hack/rasterize-icons.sh b/hack/rasterize-icons.sh index 2b6dec3b..45583e8c 100755 --- a/hack/rasterize-icons.sh +++ b/hack/rasterize-icons.sh @@ -6,7 +6,7 @@ cd "$(git rev-parse --show-toplevel)/assets" rm -rf png mkdir -p png -for SIZE in 16 32 64 128 256 512; do ( +for SIZE in 16 32 48 64 128 256 512; do ( DEST="png/icon_${SIZE}x${SIZE}.png" basename "$DEST" diff --git a/taskfile.yaml b/taskfile.yaml index fccdf7fa..2c0e547d 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -11,9 +11,9 @@ includes: tasks: build: cmds: - - cmd: sh ./hack/build-app.sh + - cmd: ./hack/build-macos.sh platforms: [darwin] - cmd: go build -ldflags='-w -s' -trimpath -o dist/gones platforms: [linux] - - cmd: go build -ldflags='-w -s' -trimpath -o dist/gones.exe + - cmd: ./hack/build-windows.sh platforms: [windows]