Skip to content

Commit

Permalink
ci: Build macOS dmg
Browse files Browse the repository at this point in the history
  • Loading branch information
lukexor committed Oct 31, 2023
1 parent c2a03e1 commit 94fdbfa
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 7 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/package-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Package macOS

# yamllint disable-line rule:truthy
on:
workflow_call:
inputs:
plan:
required: true
type: string

permissions:
contents: write

jobs:
package:
runs-on: macos-latest
env:
PLAN: ${{ inputs.plan }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch local artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: artifacts
- name: Create Package
id: package
run: |
bin_name=tetanes
app_name="TetaNES"
app_dir="$app_name.app"
# Create app dir
mkdir -p "$app_dir/Contents/MacOS"
# Copy binary
app_bin="$app_dir/Contents/MacOS/$bin_name"
archive=$(echo "$PLAN" | jq --raw-output '.artifacts[]?.path | select( . | match(".tar.xz$") )')
target=$(echo "$PLAN" | jq --raw-output '.artifacts[]? | select( .path | match(".tar.xz$") ) | .target_triples[0]')
tar xvf "$archive"
cp "$bin_name-$target/$bin_name" "$app_bin"
# Copy icon
mkdir -p "$app_dir/Contents/Resources"
cp assets/Info.plist "$app_dir/Contents"
cp assets/logo.icns "$app_dir/Contents/Resources"
# Create dmg
hdiutil create "$app_name.dmg" -srcfolder "$app_dir" -ov
echo "file=$app_name.dmg" >> "$GITHUB_OUTPUT"
- name: Update Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: ${{ steps.package.outputs.file }}
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ jobs:
done
git push
custom-package-macos:
needs: [plan, should-publish]
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
uses: ./.github/workflows/package-macos.yml
with:
plan: ${{ needs.plan.outputs.val }}
secrets: inherit

# Create a Github Release with all the results once everything is done
publish-release:
needs: [plan, should-publish]
Expand Down
10 changes: 3 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,14 @@ ci = ["github"]
# The installers to generate for each app
installers = ["shell", "powershell", "homebrew", "msi"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = [
"x86_64-unknown-linux-gnu",
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
]
targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-pc-windows-msvc"]
# Publish jobs to run in CI
pr-run-mode = "plan"
# A GitHub repo to push Homebrew formulas to
tap = "lukexor/formulae"
# Publish jobs to run in CI
publish-jobs = ["homebrew"]
publish-jobs = ["homebrew", "./package-macos"]
# Skip checking whether the specified configuration files are up to date
allow-dirty = ["msi"]

[workspace.metadata.dist.dependencies.homebrew]
Expand Down
8 changes: 8 additions & 0 deletions assets/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>logo</string>
</dict>
</plist>
Binary file added assets/logo.icns
Binary file not shown.

0 comments on commit 94fdbfa

Please sign in to comment.