From 6937939916bc0192e059aedbd03de0ba4c7acd70 Mon Sep 17 00:00:00 2001
From: tiny-craft <137850705+tiny-craft@users.noreply.github.com>
Date: Tue, 8 Aug 2023 08:45:26 +0800
Subject: [PATCH] feat: add github actions for release macOS app
---
.github/workflows/release-macos.yaml | 98 ++++++++++++++++++++++++++++
build/darwin/Info.plist | 4 +-
main.go | 5 ++
wails.json | 4 +-
4 files changed, 107 insertions(+), 4 deletions(-)
create mode 100644 .github/workflows/release-macos.yaml
diff --git a/.github/workflows/release-macos.yaml b/.github/workflows/release-macos.yaml
new file mode 100644
index 0000000..009fc62
--- /dev/null
+++ b/.github/workflows/release-macos.yaml
@@ -0,0 +1,98 @@
+name: Release macOS App
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ release:
+ name: Release macOS App
+ runs-on: macos-latest # We can cross compile but need to be on macOS to notarise
+ strategy:
+ matrix:
+ platform:
+ - darwin/amd64
+ - darwin/arm64
+ - darwin/universal
+ steps:
+ - name: Checkout source code
+ uses: actions/checkout@v2
+
+ - name: Normalise platform tag
+ id: normalise_platform
+ shell: bash
+ run: |
+ tag=$(echo ${{ matrix.platform }} | sed -e 's/\//_/g')
+ echo "tag={$tag}" >> GITHUB_OUTPUT
+
+ - name: Normalise version tag
+ id: normalise_version
+ shell: bash
+ run: |
+ version=$(echo ${{ github.event.release.tag_name }} | sed -e 's/v//g')
+ echo "version={$version}" >> GITHUB_OUTPUT
+
+ - name: Setup Go
+ uses: actions/setup-go@v4
+ with:
+ go-version: stable
+
+# - name: Install gon for macOS notarisation
+# shell: bash
+# run: wget https://github.com/mitchellh/gon/releases/download/v0.2.5/gon_macos.zip && unzip gon_macos.zip && mv gon /usr/local/bin
+#
+# - name: Import code signing certificate from Github Secrets
+# uses: Apple-Actions/import-codesign-certs@v1
+# with:
+# p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
+# p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
+
+ - name: Install wails
+ shell: bash
+ run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
+
+ - name: Setup Node
+ uses: actions/setup-node@v2
+ with:
+ node-version: '16'
+
+ - name: Build frontend assets
+ shell: bash
+ run: |
+ npm install -g npm
+ node version.js ${{ github.event.release.tag_name }}
+ cd frontend && npm install
+
+ - name: Build wails app for macOS
+ shell: bash
+ run: CGO_ENABLED=1 wails build -platform ${{ matrix.platform }} -ldflags "-X main.version=${{ github.event.release.tag_name }}"
+
+# - name: Notarise macOS app + create dmg
+# shell: bash
+# run: gon -log-level=info gon.config.json
+# env:
+# AC_USERNAME: ${{ secrets.AC_USERNAME }}
+# AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
+
+ - name: Compress macOS app
+ shell: bash
+ run: cd build/bin && zip -r TinyRDM-${{ steps.normalise_platform.outputs.tag }}.zip TinyRDM.app
+
+ - name: Get latest release from API
+ id: get_upload_url
+ shell: bash
+ run: |
+ curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/tiny-craft/tiny-rdm/releases" > /tmp/releases.json
+ url=$(jq -r '.[0].upload_url' /tmp/releases.json)
+ echo "{url}={$url}" >> $GITHUB_OUTPUT
+
+ - name: Upload artifact
+ uses: actions/upload-release-asset@v1.0.2
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ ARTIFACT_NAME: TinyRDM_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}
+ with:
+ upload_url: ${{ steps.get_upload_url.outputs.url }}
+ asset_path: ./build/bin/TinyRDM-${{ steps.normalise_platform.outputs.tag }}.zip
+ asset_name: ${{ env.ARTIFACT_NAME }}.zip
+ asset_content_type: application/zip
diff --git a/build/darwin/Info.plist b/build/darwin/Info.plist
index e7819a7..88d1860 100644
--- a/build/darwin/Info.plist
+++ b/build/darwin/Info.plist
@@ -8,7 +8,7 @@
CFBundleExecutable
{{.Name}}
CFBundleIdentifier
- com.wails.{{.Name}}
+ com.tinycraft.{{.Name}}
CFBundleVersion
{{.Info.ProductVersion}}
CFBundleGetInfoString
@@ -24,4 +24,4 @@
NSHumanReadableCopyright
{{.Info.Copyright}}
-
\ No newline at end of file
+
diff --git a/main.go b/main.go
index 773c61e..53c0ceb 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ import (
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
+ "github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"runtime"
"tinyrdm/backend/services"
@@ -72,6 +73,10 @@ func main() {
//WebviewIsTransparent: true,
//WindowIsTranslucent: true,
},
+ Linux: &linux.Options{
+ Icon: icon,
+ WebviewGpuPolicy: linux.WebviewGpuPolicyOnDemand,
+ },
})
if err != nil {
diff --git a/wails.json b/wails.json
index d9803d6..59fe550 100644
--- a/wails.json
+++ b/wails.json
@@ -1,6 +1,6 @@
{
"$schema": "https://wails.io/schemas/config.v2.json",
- "name": "Tiny RDM",
+ "name": "tinyrdm",
"outputfilename": "Tiny RDM",
"frontend:install": "npm install",
"frontend:build": "npm run build",
@@ -13,7 +13,7 @@
"info": {
"companyName": "Tiny Craft",
"productName": "Tiny RDM",
- "productVersion": "1.0.0",
+ "productVersion": "0.9.0",
"copyright": "Copyright © 2023",
"comments": "Tiny Redis Desktop Manager"
}