forked from rkvishwa/Sonar-Code-Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (160 loc) · 5.62 KB
/
Copy pathpr-validation.yml
File metadata and controls
183 lines (160 loc) · 5.62 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
name: "PR Validation (Feature -> Dev)"
on:
pull_request:
branches: [ "development" ]
jobs:
build:
name: Build for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Cache Electron Binaries
uses: actions/cache@v4
with:
path: |
~/.cache/electron
~/.cache/electron-builder
~/AppData/Local/electron/Cache
~/AppData/Local/electron-builder/Cache
key: ${{ runner.os }}-electron-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-
- name: Install Dependencies
shell: bash
run: |
for attempt in 1 2 3; do
if npm ci; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "npm ci failed after $attempt attempts"
exit 1
fi
echo "npm ci failed on attempt $attempt. Retrying in 20 seconds..."
sleep 20
done
- name: Verify Secrets Against .env.example
env:
SECRETS_JSON: ${{ toJson(secrets) }}
run: |
node -e '
const fs = require("fs");
const secrets = JSON.parse(process.env.SECRETS_JSON || "{}");
const envExample = fs.readFileSync(".env.example", "utf-8");
const missing = [];
envExample.split("\n").forEach(line => {
const trimmed = line.trim();
if (trimmed && !trimmed.startsWith("#")) {
const key = trimmed.split("=")[0];
if (!secrets[key]) {
missing.push(key);
}
}
});
if (missing.length > 0) {
console.error(`::error::Missing required secrets in GitHub Actions: ${missing.join(", ")}`);
process.exit(1);
}
'
- name: Create .env file
shell: bash
env:
SECRETS_JSON: ${{ toJson(secrets) }}
run: |
node <<'NODE'
const fs = require("fs");
const secrets = JSON.parse(process.env.SECRETS_JSON || "{}");
const envExample = fs.readFileSync(".env.example", "utf-8");
const missing = [];
const output = [];
envExample.split(/\r?\n/).forEach((line) => {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) {
return;
}
const key = trimmed.split("=")[0].trim();
if (!secrets[key]) {
missing.push(key);
return;
}
output.push(`${key}=${secrets[key]}`);
});
if (missing.length > 0) {
console.error(`Missing required secrets in GitHub Actions: ${missing.join(", ")}`);
process.exit(1);
}
fs.writeFileSync(".env", `${output.join("\n")}\n`);
console.log(`.env file created successfully with ${output.length} entries`);
NODE
- name: Verify .env file
run: |
if [ ! -f .env ]; then
echo "Error: .env file was not created"
exit 1
fi
echo ".env file exists and contains $(wc -l < .env) lines"
- name: Build macOS App
if: matrix.os == 'macos-latest'
run: npm run package:mac
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Build Windows App + Microsoft Store Package
if: matrix.os == 'windows-latest'
run: npm run package:win:all
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_SKIP_SIGNING: true
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Check Build Output (macOS)
if: matrix.os == 'macos-latest'
run: |
echo "Checking for build artifacts..."
ls -la release/ || echo "Release directory not found"
if [ -d "release" ]; then
find release -type f -name "*.dmg" -o -name "*.zip" || echo "No DMG or ZIP files found"
fi
- name: Check Build Output (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
echo "Checking for build artifacts..."
ls -la release/ || echo "Release directory not found"
if [ -d "release" ]; then
find release -type f \( -name "*.exe" -o -name "*.appx" \) || echo "No Windows EXE or APPX files found"
fi
- name: Upload macOS Artifacts
if: matrix.os == 'macos-latest' && hashFiles('release/*.dmg') != '' || hashFiles('release/*.zip') != ''
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.os }}
path: |
release/*.dmg
release/*.zip
retention-days: 3
if-no-files-found: warn
- name: Upload Windows Installer Artifact
if: matrix.os == 'windows-latest' && hashFiles('release/*.exe') != ''
uses: actions/upload-artifact@v4
with:
name: windows-installer-exe
path: release/*.exe
retention-days: 3
if-no-files-found: warn
- name: Upload Windows Store Artifact
if: matrix.os == 'windows-latest' && hashFiles('release/*.appx') != ''
uses: actions/upload-artifact@v4
with:
name: windows-store-appx
path: release/*.appx
retention-days: 3
if-no-files-found: warn