Skip to content

Commit 059591f

Browse files
RohithzrCopilot
andauthored
Add build pipeline for both signed and unsigned builds. (#29)
* Initial plan * Add comprehensive DMG build and signing pipeline with attribution Co-authored-by: Rohithzr <1592554+Rohithzr@users.noreply.github.com> * Update pipeline to build on current working branch for testing Co-authored-by: Rohithzr <1592554+Rohithzr@users.noreply.github.com> * Add unsigned DMG build pipeline for testing without certificates Co-authored-by: Rohithzr <1592554+Rohithzr@users.noreply.github.com> * add team id * Fix missing backslash in xcodebuild archive command Co-authored-by: Rohithzr <1592554+Rohithzr@users.noreply.github.com> * Use DEVELOPMENT_TEAM from repository secrets instead of hardcoded value Co-authored-by: Rohithzr <1592554+Rohithzr@users.noreply.github.com> * fix pipeline manually * fix mount perms * fix mount perms in signed build file --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Rohithzr <1592554+Rohithzr@users.noreply.github.com>
1 parent b197ee9 commit 059591f

File tree

6 files changed

+769
-1
lines changed

6 files changed

+769
-1
lines changed

.github/workflows/README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for the TrackWeight project.
4+
5+
## build-and-sign-dmg.yml
6+
7+
This workflow builds, signs (if certificates are provided), and packages the TrackWeight macOS application into a DMG file.
8+
9+
### Features
10+
11+
- **Automated Building**: Builds the Xcode project using the latest stable Xcode
12+
- **Code Signing**: Supports optional code signing with certificates
13+
- **DMG Creation**: Creates a professional DMG with proper layout and attribution
14+
- **Attribution**: Includes proper credits to the original repository (https://github.com/KrishKrosh/TrackWeight)
15+
- **Release Integration**: Can create GitHub releases with the built DMG
16+
- **Artifact Upload**: Uploads DMG as a GitHub Actions artifact
17+
18+
### Triggers
19+
20+
The workflow runs on:
21+
- Git tags starting with 'v' (e.g., v1.0.0)
22+
- Published releases
23+
- Manual workflow dispatch
24+
25+
### Setup Instructions
26+
27+
#### Required Secrets (for signed builds)
28+
29+
To enable code signing, add these secrets to your GitHub repository:
30+
31+
1. **BUILD_CERTIFICATE_BASE64**: Base64-encoded Developer ID Application certificate (.p12 file)
32+
```bash
33+
base64 -i YourCertificate.p12 | pbcopy
34+
```
35+
36+
2. **P12_PASSWORD**: Password for the .p12 certificate file
37+
38+
3. **BUILD_PROVISION_PROFILE_BASE64**: Base64-encoded provisioning profile (optional for Developer ID)
39+
```bash
40+
base64 -i YourProvisioningProfile.mobileprovision | pbcopy
41+
```
42+
43+
#### Setting up Certificates
44+
45+
1. Export your Developer ID Application certificate from Keychain Access as a .p12 file
46+
2. Convert to base64 and add as `BUILD_CERTIFICATE_BASE64` secret
47+
3. Add the certificate password as `P12_PASSWORD` secret
48+
49+
#### Unsigned Builds
50+
51+
If you don't have code signing certificates, the workflow will automatically create an unsigned development build. These builds can still be used but may require users to manually allow them in System Preferences.
52+
53+
## build-unsigned-dmg.yml
54+
55+
This workflow specifically builds unsigned development versions of the TrackWeight app without requiring any certificates.
56+
57+
### Features
58+
59+
- **No Certificate Requirements**: Builds completely without code signing
60+
- **Development Build**: Creates unsigned development builds that work on any Mac
61+
- **Same DMG Features**: Includes all the same DMG features as the signed version
62+
- **Clear User Instructions**: Includes instructions for running unsigned apps
63+
- **Attribution**: Maintains proper credits to the original repository
64+
65+
### Triggers
66+
67+
The workflow runs on:
68+
- Pushes to main branches and the current working branch
69+
- Manual workflow dispatch
70+
71+
### Benefits
72+
73+
- **Easy Testing**: Perfect for testing builds without setting up certificates
74+
- **No Configuration**: Works immediately without any secrets or setup
75+
- **User-Friendly**: Includes clear instructions for users on how to run unsigned apps
76+
77+
## Choosing the Right Workflow
78+
79+
### Use `build-and-sign-dmg.yml` when:
80+
- You have Apple Developer certificates
81+
- You want to distribute signed, trusted builds
82+
- You're creating official releases
83+
84+
### Use `build-unsigned-dmg.yml` when:
85+
- You don't have certificates
86+
- You want to test builds quickly
87+
- You're developing or experimenting
88+
- You need a simple build process
89+
90+
If no signing certificates are provided, the workflow will create an unsigned development build that can still be distributed and run locally (users may need to allow it in System Preferences > Security & Privacy).
91+
92+
### Usage
93+
94+
#### Manual Trigger
95+
1. Go to Actions tab in your GitHub repository
96+
2. Select "Build and Sign DMG" workflow
97+
3. Click "Run workflow"
98+
4. Optionally check "Create a GitHub release" to create a release
99+
100+
#### Automatic Trigger
101+
1. Create a git tag: `git tag v1.0.0`
102+
2. Push the tag: `git push origin v1.0.0`
103+
3. The workflow will automatically build and create a release
104+
105+
### Output
106+
107+
The workflow produces:
108+
- **DMG file**: TrackWeight-{version}.dmg containing the app and attribution
109+
- **GitHub Release**: (if triggered by tag or manual release creation)
110+
- **Artifacts**: DMG file uploaded as GitHub Actions artifact
111+
112+
### Attribution
113+
114+
This workflow ensures proper attribution to the original TrackWeight repository:
115+
- README.txt file included in DMG with credits
116+
- Release notes include attribution
117+
- Links to original repository: https://github.com/KrishKrosh/TrackWeight
118+
119+
## update-homebrew.yml
120+
121+
This workflow automatically updates the Homebrew cask when a new release is published.
122+
123+
### Features
124+
- Updates version in Homebrew tap repository
125+
- Automatically triggered on release publication
126+
- Can be manually triggered with version input
127+
128+
For more information about the original TrackWeight project, visit: https://github.com/KrishKrosh/TrackWeight
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
name: Build and Sign DMG
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
branches:
8+
- 'copilot/fix-1' # Enable testing on current working branch
9+
release:
10+
types: [published]
11+
workflow_dispatch:
12+
inputs:
13+
create_release:
14+
description: 'Create a GitHub release'
15+
required: false
16+
default: false
17+
type: boolean
18+
19+
env:
20+
APP_NAME: TrackWeight
21+
SCHEME: TrackWeight
22+
CONFIGURATION: Release
23+
24+
jobs:
25+
build-and-sign:
26+
runs-on: macos-latest
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
submodules: recursive
33+
34+
- name: Setup Xcode
35+
uses: maxim-lobanov/setup-xcode@v1
36+
with:
37+
xcode-version: latest-stable
38+
39+
- name: Import Code-Signing Certificates
40+
if: ${{ secrets.BUILD_CERTIFICATE_BASE64 != '' }}
41+
uses: Apple-Actions/import-codesign-certs@v2
42+
with:
43+
p12-file-base64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
44+
p12-password: ${{ secrets.P12_PASSWORD }}
45+
46+
- name: Install provisioning profile
47+
if: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 != '' }}
48+
env:
49+
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
50+
run: |
51+
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
52+
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
53+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
54+
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
55+
56+
- name: Build and Archive App
57+
run: |
58+
xcodebuild \
59+
-project TrackWeight.xcodeproj \
60+
-scheme ${{ env.SCHEME }} \
61+
-configuration ${{ env.CONFIGURATION }} \
62+
-archivePath "$RUNNER_TEMP/${{ env.APP_NAME }}.xcarchive" \
63+
archive
64+
65+
- name: Export App
66+
run: |
67+
# Use development export method if no signing certificates are available
68+
if [ -z "${{ secrets.BUILD_CERTIFICATE_BASE64 }}" ]; then
69+
# Create export options for unsigned build
70+
cat > "$RUNNER_TEMP/ExportOptions.plist" << EOF
71+
<?xml version="1.0" encoding="UTF-8"?>
72+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
73+
<plist version="1.0">
74+
<dict>
75+
<key>method</key>
76+
<string>debugging</string>
77+
<key>signingStyle</key>
78+
<string>manual</string>
79+
<key>stripSwiftSymbols</key>
80+
<true/>
81+
<key>destination</key>
82+
<string>export</string>
83+
<key>signingCertificate</key>
84+
<string>-</string>
85+
<key>teamID</key>
86+
<string>-</string>
87+
<key>uploadBitcode</key>
88+
<false/>
89+
<key>uploadSymbols</key>
90+
<false/>
91+
</dict>
92+
</plist>
93+
EOF
94+
else
95+
# Use the existing ExportOptions.plist for signed builds
96+
cp ExportOptions.plist "$RUNNER_TEMP/ExportOptions.plist"
97+
fi
98+
99+
xcodebuild \
100+
-archivePath "$RUNNER_TEMP/${{ env.APP_NAME }}.xcarchive" \
101+
-exportPath "$RUNNER_TEMP/export" \
102+
-exportOptionsPlist "$RUNNER_TEMP/ExportOptions.plist" \
103+
-exportArchive
104+
105+
- name: Install create-dmg
106+
run: |
107+
brew install create-dmg
108+
109+
- name: Create README file
110+
run: |
111+
# Create a README with attribution
112+
cat > "$RUNNER_TEMP/export/README.txt" << 'EOF'
113+
TrackWeight - MacBook Trackpad Digital Scale
114+
115+
This application transforms your MacBook's trackpad into a precise digital weighing scale.
116+
117+
CREDITS:
118+
Original repository: https://github.com/KrishKrosh/TrackWeight
119+
Created by: Krish Shah (@KrishKrosh)
120+
121+
This build was created from a fork at: https://github.com/Rohithzr/TrackWeight
122+
123+
USAGE:
124+
1. Open the scale
125+
2. Rest your finger on the trackpad
126+
3. While maintaining finger contact, put your object on the trackpad
127+
4. Try to put as little pressure on the trackpad while still maintaining contact
128+
129+
REQUIREMENTS:
130+
- macOS 13.0 or later
131+
- MacBook with Force Touch trackpad (2015 or newer MacBook Pro, 2016 or newer MacBook)
132+
- App Sandbox must be disabled for trackpad access
133+
134+
LICENSE: MIT License
135+
136+
For more information, visit the original repository:
137+
https://github.com/KrishKrosh/TrackWeight
138+
EOF
139+
140+
- name: Create DMG
141+
run: |
142+
# Create DMG with proper attribution to original repository
143+
create-dmg \
144+
--volname "${{ env.APP_NAME }}" \
145+
--volicon "$RUNNER_TEMP/export/${{ env.APP_NAME }}.app/Contents/Resources/AppIcon.icns" \
146+
--window-pos 200 120 \
147+
--window-size 600 300 \
148+
--icon-size 100 \
149+
--icon "${{ env.APP_NAME }}.app" 175 120 \
150+
--hide-extension "${{ env.APP_NAME }}.app" \
151+
--app-drop-link 425 120 \
152+
--hdiutil-quiet \
153+
"$RUNNER_TEMP/${{ env.APP_NAME }}.dmg" \
154+
"$RUNNER_TEMP/export/"
155+
156+
- name: Get version info
157+
id: version_info
158+
run: |
159+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
160+
VERSION=${GITHUB_REF#refs/tags/}
161+
else
162+
VERSION=$(date +%Y%m%d-%H%M%S)
163+
fi
164+
echo "version=$VERSION" >> $GITHUB_OUTPUT
165+
echo "dmg_name=${{ env.APP_NAME }}-$VERSION.dmg" >> $GITHUB_OUTPUT
166+
167+
- name: Rename DMG with version
168+
run: |
169+
mv "$RUNNER_TEMP/${{ env.APP_NAME }}.dmg" "$RUNNER_TEMP/${{ steps.version_info.outputs.dmg_name }}"
170+
171+
- name: Upload DMG as artifact
172+
uses: actions/upload-artifact@v4
173+
with:
174+
name: ${{ steps.version_info.outputs.dmg_name }}
175+
path: ${{ runner.temp }}/${{ steps.version_info.outputs.dmg_name }}
176+
retention-days: 30
177+
178+
- name: Create Release
179+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true')
180+
uses: softprops/action-gh-release@v1
181+
with:
182+
tag_name: ${{ steps.version_info.outputs.version }}
183+
name: ${{ env.APP_NAME }} ${{ steps.version_info.outputs.version }}
184+
body: |
185+
# TrackWeight ${{ steps.version_info.outputs.version }}
186+
187+
Transform your MacBook's trackpad into a precise digital weighing scale!
188+
189+
## Credits
190+
**Original repository:** https://github.com/KrishKrosh/TrackWeight
191+
**Created by:** Krish Shah (@KrishKrosh)
192+
193+
This build is from the fork at https://github.com/Rohithzr/TrackWeight
194+
195+
## Installation
196+
1. Download the DMG file below
197+
2. Open the DMG and drag TrackWeight.app to your Applications folder
198+
3. Run the app and follow the setup instructions
199+
200+
## Requirements
201+
- macOS 13.0 or later
202+
- MacBook with Force Touch trackpad (2015 or newer MacBook Pro, 2016 or newer MacBook)
203+
204+
## Usage
205+
1. Open the scale
206+
2. Rest your finger on the trackpad
207+
3. While maintaining finger contact, put your object on the trackpad
208+
4. Apply minimal pressure while maintaining contact to get the weight
209+
210+
For more information, visit the [original repository](https://github.com/KrishKrosh/TrackWeight).
211+
files: |
212+
${{ runner.temp }}/${{ steps.version_info.outputs.dmg_name }}
213+
draft: false
214+
prerelease: false
215+
env:
216+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217+
218+
- name: Summary
219+
run: |
220+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
221+
echo "✅ Successfully built and packaged TrackWeight DMG" >> $GITHUB_STEP_SUMMARY
222+
echo "📦 DMG file: ${{ steps.version_info.outputs.dmg_name }}" >> $GITHUB_STEP_SUMMARY
223+
echo "🔗 Original repository: https://github.com/KrishKrosh/TrackWeight" >> $GITHUB_STEP_SUMMARY
224+
echo "" >> $GITHUB_STEP_SUMMARY
225+
echo "The DMG includes:" >> $GITHUB_STEP_SUMMARY
226+
echo "- TrackWeight.app (signed if certificates provided)" >> $GITHUB_STEP_SUMMARY
227+
echo "- README.txt with attribution and usage instructions" >> $GITHUB_STEP_SUMMARY
228+
echo "- Proper credits to the original repository" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)