From ea4858962d55dd23b1bfc469d3d50ed3c1ce1e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nh=C3=A2n?= Date: Sat, 9 Jul 2022 23:58:41 +0700 Subject: [PATCH] github actions: proper mac application bundle --- .github/workflows/main.yml | 15 +++++++++++---- Makefile | 3 ++- README.md | 30 +++++++++++++++++++++++++++-- icon.icns | Bin 0 -> 2943 bytes scripts/make-mac-bundle.sh | 38 +++++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 icon.icns create mode 100755 scripts/make-mac-bundle.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a7900fe..b339dfc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-10.15] runs-on: ${{ matrix.os }} @@ -24,14 +24,21 @@ jobs: run: make deps-debian - name: Build for ${{ runner.os }} + env: + TAG: ${{ github.ref_name }} run: make $(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]') # The `tr` stuff is to convert the string to lowercase + - name: Zip first to prevent GH Artifacts from removing the executable flag + run: | + cd dist + zip -vr "shark-${{ runner.os }}.zip" . + - name: Upload ${{ runner.os }} build uses: actions/upload-artifact@v3 with: name: ${{ runner.os }} shark - path: dist/* + path: dist/shark-${{ runner.os }}.zip - name: Cross-compile Windows build if: runner.os == 'Linux' @@ -53,7 +60,7 @@ jobs: # Because we have multiple OSes in the build matrix, we need to either # create a new release, or upload to the release if it already exists. if gh release view "$TAG"; then - gh release upload "$TAG" dist/* + gh release upload "$TAG" dist/*.zip dist/*.exe else # Work around GH being daft: # https://github.com/actions/checkout/issues/290 @@ -63,5 +70,5 @@ jobs: git tag -l --format='%(contents)' "$TAG" >> RELEASE_NOTES echo '```' >> RELEASE_NOTES cat RELEASE_NOTES - gh release create "$TAG" dist/* -F RELEASE_NOTES + gh release create "$TAG" dist/*.zip dist/*.exe -F RELEASE_NOTES fi diff --git a/Makefile b/Makefile index 695faba..149aeed 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,10 @@ windows: macos: GOOS=darwin GOARCH=amd64 go build -tags ebitensinglethread -o dist/shark-macos + ./scripts/make-mac-bundle.sh dist/shark-macos clean: - rm -f dist/* + rm -rf dist/* # https://ebiten.org/documents/install.html#Debian_/_Ubuntu deps-debian: diff --git a/README.md b/README.md index a6b8e68..1cf7245 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,33 @@ macOS builds. Such is life. # Usage -Simply run the provided binary for your OS. Mac & Linux users may need to first -make the file executable with `chmod +x `. +## Windows & Linux + +Simply unzip then run the `shark-windows.exe` or `shark-linux` executable. + +## macOS + +Since I'm not participating in Apple's $99/yr [protection racket][pr], macOS +users will need to jump through some hoops to run this program: + +- Double click on the downloaded zip file to get the `Shark` app bundle. + (skip this step if you downloaded using Safari, which automatically unzips) +- Drag the `Shark` app bundle into your `Applications` folder. +- Right-click on `Shark` -> `Open`. You'll see a warning pop-up saying this + application was created by an unverified developer (yours truly). Note: you + must **right-click instead of double-clicking**, because double-clicking will + open a different pop-up which hides the option to open the app. + +![](https://user-images.githubusercontent.com/1446315/178136989-247b5d70-ee37-47a6-95b2-a726103b95f3.png) + +- Click "Open" anyway. +- From now on you can launch the Shark application just like any other app, + either from Spotlight or from the Applications folder. + +In the future I might pay the $99 if I end up writing more macOS apps and this +becomes enough of a nuisance. Maybe. + +## Options If run from a terminal, use the `-h` argument to see available options. Windows users can [create a shortcut][7] to save their desired options. @@ -90,3 +115,4 @@ this program. If not, see . [srht]: https://builds.sr.ht/~nhanb/shark/commits/master [gh]: https://github.com/nhanb/shark/actions/workflows/main.yml +[pr]: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution diff --git a/icon.icns b/icon.icns new file mode 100644 index 0000000000000000000000000000000000000000..857c955a252ce4e1831411a69ba01e56a7914dd8 GIT binary patch literal 2943 zcmdUwPi`AG6o=o;$cl?18=`>kk!}iPn>8=dRnW8r)B|)#$&%BDP#)mq9f1_l$H?gSFfj7F!u~v1RS}jRb5@`mPK!(x}_k znh{Gh&8(@|jdxj7*W@Q}C&tmwf=G4uq;NBFx_=bc1e$iUGupQUe%T;>E`}; z#693Jx16=7i?NJzcjWw}At$4wZddTiQSY^^X*$Rz{v|H1?HK=%F2=p(buVKaEudM6 zA4RZ%4f{^|Xf3>9@2d@RaZ@@QcXEYPN`w?VgS9cSB3(tAQ0Hk6 z>?QV&b*q=oTJ)&tlBVSPZS=CNHENZ!J6dLMp)abtCy7g4)M?nrteV16TynNc5&Yf?j;(xk1WS$K2Y$BVcY5Qm zf&MTEU4ftVGz5GWCHX@yslmq@_&8OA@6g~Q>qgOlzm(je@n`K;uA}8b^-f*t4+k9@ zUD~(?8E1Q1fx*-r4wXStGe3$egGmmJK|4fl2@EqB=5-h|80NeWyudJz0Stp=FvJE! zY%t6rfFU**VuN7@!;ry{WhohE@C+g342D@<84Ov2VO@e@rm;*P>OAcM!->6M$W|~6 z0X=KFNmGJ>x|g*^t#Wqfz#RlI%xVF+Lt z6hqW7DTaaSV2GfiMuqKkqX$+q2=Aug0K5)?mn~8iuQeAz8stucDhKw`v%M0ERhmp?aro>Q^fr8eN7AhS`Ol zR={xTRx56s(SRY1j7$QrtQv-4$lTJ0AAbHxWN|Hzo^pO3`5w%(R=*G4v+*DG^DUpt z^!Mob0$u+%JwH!`<2tKQ_w;k#@U;4n;5qqR;90$GcwYWr`h{@q@S@Cy7xb@Q?uN@p m5ZJ%)fWQS+2Ye}B_#+~(pHI*LdqIC*eu#IO6!{m^dX?+| literal 0 HcmV?d00001 diff --git a/scripts/make-mac-bundle.sh b/scripts/make-mac-bundle.sh new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/scripts/make-mac-bundle.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env sh +set -euf + +echo "Current version: $TAG" + +MAC_EXECUTABLE="$1" +MAC_ICON=icon.icns +MAC_BUNDLE_DIR=dist/Shark.app + +mkdir -p $MAC_BUNDLE_DIR/Contents/Resources +mkdir -p $MAC_BUNDLE_DIR/Contents/MacOS + +cp "$MAC_ICON" $MAC_BUNDLE_DIR/Contents/Resources/Shark.icns +cp "$MAC_EXECUTABLE" $MAC_BUNDLE_DIR/Contents/MacOS/Shark +chmod +x $MAC_BUNDLE_DIR/Contents/MacOS/Shark + +cat <> $MAC_BUNDLE_DIR/Contents/Info.plist + + + CFBundleExecutable + Shark + CFBundleGetInfoString + Shark $TAG + CFBundleVersion + 0.2 + CFBundleShortVersionString + 0.2 + CFBundleIconFile + Shark + CFBundleIdentifier + com.imnhan.shark + LSUIElement + + + +EOT + +rm "$MAC_EXECUTABLE"