-
Notifications
You must be signed in to change notification settings - Fork 168
185 lines (154 loc) · 6.34 KB
/
Copy pathpr-build-dmg.yml
File metadata and controls
185 lines (154 loc) · 6.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: "PR: Build DMG on Comment"
on:
issue_comment:
types: [created]
# Restrict workflow permissions - comment jobs get write access separately
permissions:
contents: read
concurrency:
group: pr-dmg-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
build-dmg:
name: Build macOS DMG for PR
runs-on: macos-latest-xlarge
timeout-minutes: 180
# Only run for PR comments (not issue comments) that contain /dmg
# And only allow trusted users (org members, collaborators, repo owners)
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, '/dmg') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')
permissions:
contents: read
packages: read
outputs:
pr-sha: ${{ steps.pr.outputs.sha }}
steps:
- name: Get PR details
id: pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get PR information
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
echo "sha=$(echo "$PR_DATA" | jq -r .head.sha)" >> $GITHUB_OUTPUT
echo "ref=$(echo "$PR_DATA" | jq -r .head.ref)" >> $GITHUB_OUTPUT
echo "repo=$(echo "$PR_DATA" | jq -r .head.repo.full_name)" >> $GITHUB_OUTPUT
- name: Checkout PR branch
uses: actions/checkout@v7
with:
repository: ${{ steps.pr.outputs.repo }}
ref: ${{ steps.pr.outputs.ref }}
fetch-depth: 0
submodules: recursive
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
- name: Install dependencies
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
npm_config_arch: arm64
run: |
npm install --prefix build --fetch-timeout 120000
npm ci --fetch-timeout 120000
- name: Build Positron
env:
npm_config_arch: arm64
run: |
npm run gulp vscode-darwin-arm64
- name: Create DMG
run: |
# Install dmgbuild using uv
brew install uv
# The build outputs to the parent directory of the repo
# Verify the app exists where we expect it
ls -la ../VSCode-darwin-arm64/Positron.app || {
echo "Error: Positron.app not found at expected location"
echo "Contents of parent directory:"
ls -la ..
exit 1
}
# Create DMG using absolute path to the app
export POSITRON_BUNDLE_NAME=Positron-PR-${{ github.event.issue.number }}-arm64
export APP_PATH="$(cd .. && pwd)/VSCode-darwin-arm64/Positron.app"
uvx --python 3.12 --from 'dmgbuild==1.6.7' dmgbuild \
-s "${{ github.workspace }}/resources/darwin/dmg/dmg-settings.py" \
-D app_path="${APP_PATH}" \
-D app_name="Positron.app" \
-D background="${{ github.workspace }}/resources/darwin/dmg/background.png" \
-D icon="${{ github.workspace }}/resources/darwin/dmg/volume-icon.icns" \
"${POSITRON_BUNDLE_NAME}" \
"${{ github.workspace }}/${POSITRON_BUNDLE_NAME}.dmg"
- name: Upload DMG artifact
id: upload
uses: actions/upload-artifact@v7
with:
name: positron-pr-${{ github.event.issue.number }}-macos-arm64-dmg
path: Positron-PR-${{ github.event.issue.number }}-arm64.dmg
retention-days: 7
post-start-comment:
name: Post build started comment
runs-on: ubuntu-latest
if: |
github.event.issue.pull_request &&
contains(github.event.comment.body, '/dmg') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')
permissions:
pull-requests: write
issues: write
steps:
- name: Get PR details
id: pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
echo "sha=$(echo "$PR_DATA" | jq -r .head.sha)" >> $GITHUB_OUTPUT
- name: Post initial comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-F body="🔨 Building macOS DMG for commit ${{ steps.pr.outputs.sha }}... This will take approximately 15-25 minutes.
**Status:** In Progress ⏳
[View workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
post-result-comment:
name: Post build result comment
runs-on: ubuntu-latest
needs: build-dmg
if: always()
permissions:
pull-requests: write
issues: write
steps:
- name: Post success comment
if: needs.build-dmg.result == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-F body="✅ macOS DMG build completed successfully!
**Commit:** ${{ needs.build-dmg.outputs.pr-sha }}
**Artifact:** \`positron-pr-${{ github.event.issue.number }}-macos-arm64-dmg\`
📦 [Download DMG](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
The DMG will be available for 7 days.
**⚠️ Installation:** This build is unsigned and not notarized. After installing, you'll need to remove the quarantine attribute:
\`\`\`bash
xattr -dr com.apple.quarantine /Applications/Positron.app
\`\`\`"
- name: Post failure comment
if: needs.build-dmg.result == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-F body="❌ macOS DMG build failed.
[View workflow logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details."