Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 24 additions & 78 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,95 +8,41 @@ permissions:
packages: write

jobs:
macutil_build:
runs-on: ubuntu-latest
macos-app:
uses: ./.github/workflows/macos-app.yml

publish:
needs: macos-app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'

- name: Cache .NET packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Restore dependencies
run: dotnet restore MacUtilGUI/MacUtilGUI.fsproj

- name: Build and publish macOS x64
- name: Read version
id: version
run: |
dotnet publish MacUtilGUI/MacUtilGUI.fsproj \
--configuration Release \
--runtime osx-x64 \
--self-contained true \
--output ./build/osx-x64 \
/p:PublishSingleFile=true \
/p:IncludeNativeLibrariesForSelfExtract=true
set -euo pipefail
bash scripts/check-version.sh
version=$(sed -n 's/.*<CFBundleVersion>\([^<]*\)<\/CFBundleVersion>.*/\1/p' MacUtilGUI/MacUtilGUI.fsproj | head -n 1)
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Build and publish macOS ARM64
run: |
dotnet publish MacUtilGUI/MacUtilGUI.fsproj \
--configuration Release \
--runtime osx-arm64 \
--self-contained true \
--output ./build/osx-arm64 \
/p:PublishSingleFile=true \
/p:IncludeNativeLibrariesForSelfExtract=true

- name: Rename binaries
run: |
mv ./build/osx-x64/MacUtilGUI ./build/osx-x64/macutil-macos-x64
mv ./build/osx-arm64/MacUtilGUI ./build/osx-arm64/macutil-macos-arm64

- name: Extract Version
id: extract_version
run: |
# Fetch all tags
git fetch --tags

# Get the latest tag, default to 0.0.0 if no tags exist
latest_tag=$(git tag --sort=-version:refname | head -n1)
if [ -z "$latest_tag" ]; then
latest_tag="0.0.0"
fi

# Parse the latest tag (assuming format X.Y.Z)
IFS='.' read -ra VERSION_PARTS <<< "$latest_tag"
major=${VERSION_PARTS[0]:-0}
minor=${VERSION_PARTS[1]:-0}
patch=${VERSION_PARTS[2]:-0}

# Increment minor version by 0.1 (increment minor, reset patch to 0)
new_minor=$((minor + 1))
version="${major}.${new_minor}.0"

echo "Previous version: $latest_tag"
echo "New version: $version"
echo "version=$version" >> $GITHUB_ENV
shell: bash
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
pattern: MacUtil-*
merge-multiple: true

- name: Create and Upload Release
id: create_release
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.version }}
name: Pre-Release ${{ env.version }}
body: |
![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/macutil/${{ env.version }}/macutil-macos-x64)
![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/macutil/${{ env.version }}/macutil-macos-arm64)

append_body: true
tag_name: ${{ steps.version.outputs.version }}
name: Pre-Release ${{ steps.version.outputs.version }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./build/osx-x64/macutil-macos-x64
./build/osx-arm64/macutil-macos-arm64
./artifacts/MacUtil-Universal.zip
./artifacts/MacUtil-macos-x64.zip
./artifacts/MacUtil-macos-arm64.zip
prerelease: true
env:
version: ${{ env.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
200 changes: 200 additions & 0 deletions .github/workflows/macos-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: macOS App

on:
workflow_call:
workflow_dispatch:
push:
branches: ["main"]
paths:
- "MacUtilGUI/**"
- "config/**"
- "scripts/check-version.sh"
- ".github/workflows/macos-app.yml"
- ".github/workflows/Release.yml"
pull_request:
branches: ["main"]
paths:
- "MacUtilGUI/**"
- "config/**"
- "scripts/check-version.sh"
- ".github/workflows/macos-app.yml"
- ".github/workflows/Release.yml"

permissions:
contents: read

jobs:
macos-13:
name: macos-13
runs-on: macos-13
timeout-minutes: 30
steps:
- uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"

- name: Cache .NET packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Check version lock
run: bash scripts/check-version.sh

- name: Publish osx-x64
run: |
set -euo pipefail
dotnet publish MacUtilGUI/MacUtilGUI.fsproj \
--configuration Release \
--runtime osx-x64 \
--self-contained true \
--output ./build/osx-x64 \
/p:PublishSingleFile=true \
/p:IncludeNativeLibrariesForSelfExtract=true
file ./build/osx-x64/MacUtilGUI
lipo -info ./build/osx-x64/MacUtilGUI

- name: Smoke osx-x64
run: |
set -euo pipefail
chmod +x ./build/osx-x64/MacUtilGUI
./build/osx-x64/MacUtilGUI > /tmp/macutil-smoke.log 2>&1 &
pid=$!
sleep 8
if ! kill -0 "$pid" 2>/dev/null; then
echo "smoke failed: osx-x64 process died before 8s" >&2
cat /tmp/macutil-smoke.log >&2 || true
exit 1
fi
kill "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
echo "smoke ok: osx-x64 pid $pid stayed up 8s"

- name: Package Intel app
run: |
set -euo pipefail
bundle="./dist/MacUtil-Intel.app"
mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources"
rsync -a ./build/osx-x64/ "$bundle/Contents/MacOS/"
chmod +x "$bundle/Contents/MacOS/MacUtilGUI"
cp MacUtilGUI/Info.plist "$bundle/Contents/Info.plist"
cp MacUtilGUI/MacUtilGUI.icns "$bundle/Contents/Resources/"
ditto -c -k --keepParent "$bundle" ./dist/MacUtil-macos-x64.zip

- name: Upload osx-x64 binary
uses: actions/upload-artifact@v4
with:
name: osx-x64
path: ./build/osx-x64/MacUtilGUI
if-no-files-found: error

- name: Upload Intel app
uses: actions/upload-artifact@v4
with:
name: MacUtil-macos-x64
path: ./dist/MacUtil-macos-x64.zip
if-no-files-found: error

macos-14:
name: macos-14
runs-on: macos-14
timeout-minutes: 30
needs: macos-13
steps:
- uses: actions/checkout@v5

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"

- name: Cache .NET packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-

- name: Check version lock
run: bash scripts/check-version.sh

- name: Publish osx-arm64
run: |
set -euo pipefail
dotnet publish MacUtilGUI/MacUtilGUI.fsproj \
--configuration Release \
--runtime osx-arm64 \
--self-contained true \
--output ./build/osx-arm64 \
/p:PublishSingleFile=true \
/p:IncludeNativeLibrariesForSelfExtract=true
file ./build/osx-arm64/MacUtilGUI
lipo -info ./build/osx-arm64/MacUtilGUI

- name: Download osx-x64 binary
uses: actions/download-artifact@v4
with:
name: osx-x64
path: ./build/osx-x64

- name: Smoke osx-arm64
run: |
set -euo pipefail
chmod +x ./build/osx-arm64/MacUtilGUI
./build/osx-arm64/MacUtilGUI > /tmp/macutil-smoke.log 2>&1 &
pid=$!
sleep 8
if ! kill -0 "$pid" 2>/dev/null; then
echo "smoke failed: osx-arm64 process died before 8s" >&2
cat /tmp/macutil-smoke.log >&2 || true
exit 1
fi
kill "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
echo "smoke ok: osx-arm64 pid $pid stayed up 8s"

- name: Lipo universal app
run: |
set -euo pipefail
chmod +x ./build/osx-x64/MacUtilGUI ./build/osx-arm64/MacUtilGUI
bundle="./dist/MacUtil-Universal.app"
mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources"
rsync -a --exclude="MacUtilGUI" ./build/osx-arm64/ "$bundle/Contents/MacOS/"
lipo -create \
./build/osx-x64/MacUtilGUI \
./build/osx-arm64/MacUtilGUI \
-output "$bundle/Contents/MacOS/MacUtilGUI"
chmod +x "$bundle/Contents/MacOS/MacUtilGUI"
cp MacUtilGUI/Info.plist "$bundle/Contents/Info.plist"
cp MacUtilGUI/MacUtilGUI.icns "$bundle/Contents/Resources/"
file "$bundle/Contents/MacOS/MacUtilGUI"
lipo -info "$bundle/Contents/MacOS/MacUtilGUI"
lipo -info "$bundle/Contents/MacOS/MacUtilGUI" | grep x86_64
lipo -info "$bundle/Contents/MacOS/MacUtilGUI" | grep arm64
arm_bundle="./dist/MacUtil-AppleSilicon.app"
mkdir -p "$arm_bundle/Contents/MacOS" "$arm_bundle/Contents/Resources"
rsync -a ./build/osx-arm64/ "$arm_bundle/Contents/MacOS/"
chmod +x "$arm_bundle/Contents/MacOS/MacUtilGUI"
cp MacUtilGUI/Info.plist "$arm_bundle/Contents/Info.plist"
cp MacUtilGUI/MacUtilGUI.icns "$arm_bundle/Contents/Resources/"
ditto -c -k --keepParent "$bundle" ./dist/MacUtil-Universal.zip
ditto -c -k --keepParent "$arm_bundle" ./dist/MacUtil-macos-arm64.zip

- name: Upload Apple Silicon app
uses: actions/upload-artifact@v4
with:
name: MacUtil-macos-arm64
path: ./dist/MacUtil-macos-arm64.zip
if-no-files-found: error

- name: Upload universal app
uses: actions/upload-artifact@v4
with:
name: MacUtil-Universal
path: ./dist/MacUtil-Universal.zip
if-no-files-found: error
15 changes: 5 additions & 10 deletions MacUtilGUI/build_universal.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ echo
APP_NAME="MacUtilGUI"
BUNDLE_NAME="MacUtil"
BUNDLE_IDENTIFIER="com.macutil.gui"
VERSION="0.2.0"
VERSION="0.2.1"
COPYRIGHT="Copyright © 2025 CT Tech Group LLC. All rights reserved."

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

print_status() {
Expand Down Expand Up @@ -45,16 +44,14 @@ dotnet restore > /dev/null

# Build for Intel x64
print_status "Building Intel x64 binary..."
dotnet publish -c Release -r osx-x64 -p:UseAppHost=true --self-contained true -o ./bin/Release/net9.0/publish/osx-x64/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
if ! dotnet publish -c Release -r osx-x64 -p:UseAppHost=true --self-contained true -o ./bin/Release/net9.0/publish/osx-x64/ > /dev/null 2>&1; then
print_error "Intel x64 build failed"
exit 1
fi

# Build for Apple Silicon ARM64
print_status "Building Apple Silicon ARM64 binary..."
dotnet publish -c Release -r osx-arm64 -p:UseAppHost=true --self-contained true -o ./bin/Release/net9.0/publish/osx-arm64/ > /dev/null 2>&1
if [ $? -ne 0 ]; then
if ! dotnet publish -c Release -r osx-arm64 -p:UseAppHost=true --self-contained true -o ./bin/Release/net9.0/publish/osx-arm64/ > /dev/null 2>&1; then
print_error "Apple Silicon ARM64 build failed"
exit 1
fi
Expand All @@ -67,12 +64,10 @@ mkdir -p "$universal_app/Contents/Resources"

# Create universal binary using lipo
print_status "Merging binaries with lipo..."
lipo -create \
if ! lipo -create \
"./bin/Release/net9.0/publish/osx-x64/$APP_NAME" \
"./bin/Release/net9.0/publish/osx-arm64/$APP_NAME" \
-output "$universal_app/Contents/MacOS/$APP_NAME" 2>/dev/null

if [ $? -ne 0 ]; then
-output "$universal_app/Contents/MacOS/$APP_NAME" 2>/dev/null; then
print_error "Failed to create universal binary with lipo"
exit 1
fi
Expand Down
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[default.extend-identifiers]
typ = "typ"
Loading
Loading