This repository was archived by the owner on Apr 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
184 lines (165 loc) · 6.45 KB
/
Copy pathci.yml
File metadata and controls
184 lines (165 loc) · 6.45 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
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run format
- name: Type check
run: npm run typecheck
build-mac-dev:
needs: typecheck
strategy:
matrix:
include:
- os: macos-latest
arch: arm64
- os: macos-15-intel
arch: x64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Build dev package
run: npm run package:dev -- --${{ matrix.arch }} --publish=never
- name: Calculate artifact sizes
id: sizes
run: |
# Calculate sizes and format them
echo "Calculating artifact sizes..."
# Find DMG and ZIP files
DMG_FILE=$(find release-dev -name "*-${{ matrix.arch }}.dmg" -type f | head -n 1)
ZIP_FILE=$(find release-dev -name "*-${{ matrix.arch }}.zip" -type f | head -n 1)
# Get sizes in bytes and convert to human-readable format
if [ -f "$DMG_FILE" ]; then
DMG_SIZE_BYTES=$(stat -f%z "$DMG_FILE" 2>/dev/null || stat -c%s "$DMG_FILE" 2>/dev/null)
DMG_SIZE_MB=$(echo "scale=2; $DMG_SIZE_BYTES / 1048576" | bc)
echo "dmg_size=${DMG_SIZE_MB} MB" >> $GITHUB_OUTPUT
else
echo "dmg_size=N/A" >> $GITHUB_OUTPUT
fi
if [ -f "$ZIP_FILE" ]; then
ZIP_SIZE_BYTES=$(stat -f%z "$ZIP_FILE" 2>/dev/null || stat -c%s "$ZIP_FILE" 2>/dev/null)
ZIP_SIZE_MB=$(echo "scale=2; $ZIP_SIZE_BYTES / 1048576" | bc)
echo "zip_size=${ZIP_SIZE_MB} MB" >> $GITHUB_OUTPUT
else
echo "zip_size=N/A" >> $GITHUB_OUTPUT
fi
# Create a size info file for the comment job
mkdir -p size-info
echo "DMG: ${DMG_SIZE_MB:-N/A} MB" > size-info/${{ matrix.arch }}-sizes.txt
echo "ZIP: ${ZIP_SIZE_MB:-N/A} MB" >> size-info/${{ matrix.arch }}-sizes.txt
cat size-info/${{ matrix.arch }}-sizes.txt
- name: Upload size info
uses: actions/upload-artifact@v4
with:
name: size-info-${{ matrix.arch }}
path: size-info/${{ matrix.arch }}-sizes.txt
if-no-files-found: error
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: neovate-dev-${{ matrix.arch }}
path: release-dev/*-${{ matrix.arch }}.*
if-no-files-found: error
comment:
needs: build-mac-dev
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
permissions:
pull-requests: write
steps:
- name: Download size info artifacts
uses: actions/download-artifact@v4
with:
pattern: size-info-*
path: size-info
- name: Post PR comment with artifact links
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
const identifier = '<!-- neovate-build -->';
const readSizeInfo = (arch) => {
try {
const sizeFile = path.join('size-info', `size-info-${arch}`, `${arch}-sizes.txt`);
const content = fs.readFileSync(sizeFile, 'utf8');
const lines = content.trim().split('\n');
const dmgLine = lines.find(l => l.startsWith('DMG:'));
const zipLine = lines.find(l => l.startsWith('ZIP:'));
const dmgSize = dmgLine ? dmgLine.split(':')[1].trim() : 'N/A';
const zipSize = zipLine ? zipLine.split(':')[1].trim() : 'N/A';
return { dmg: dmgSize, zip: zipSize };
} catch (error) {
console.error(`Error reading size info for ${arch}:`, error);
return { dmg: 'N/A', zip: 'N/A' };
}
};
const arm64Sizes = readSizeInfo('arm64');
const x64Sizes = readSizeInfo('x64');
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const arm64 = artifacts.find(a => a.name === 'neovate-dev-arm64');
const x64 = artifacts.find(a => a.name === 'neovate-dev-x64');
const artifactUrl = (artifact) =>
`https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts/${artifact.id}`;
const body = [
identifier,
'## Build Ready',
'',
'| Architecture | Download | DMG Size | ZIP Size |',
'|--------------|----------|----------|----------|',
`| Apple Silicon | ${arm64 ? `[Download](${artifactUrl(arm64)})` : 'N/A'} | ${arm64Sizes.dmg} | ${arm64Sizes.zip} |`,
`| Intel | ${x64 ? `[Download](${artifactUrl(x64)})` : 'N/A'} | ${x64Sizes.dmg} | ${x64Sizes.zip} |`,
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes(identifier));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}