Skip to content

Commit 7b92fb3

Browse files
committed
fix(ci): release merged latest-mac.yml
1 parent 8dcbb1e commit 7b92fb3

File tree

4 files changed

+147
-7
lines changed

4 files changed

+147
-7
lines changed

.github/workflows/release-ui-tars.yml

+97-7
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ permissions:
1717

1818
jobs:
1919
publish_on_mac:
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
os: [macos-latest, macos-13]
24-
runs-on: ${{ matrix.os }}
20+
runs-on: macos-latest
2521
steps:
2622
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2723
- name: Show operating system info
@@ -70,7 +66,6 @@ jobs:
7066
- name: install dependencies
7167
run: pnpm install
7268
- name: publish arm64
73-
if: matrix.os == 'macos-latest'
7469
env:
7570
APPLE_ID: ${{ secrets.APPLE_ID }}
7671
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
@@ -79,8 +74,63 @@ jobs:
7974
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8075
run: |
8176
cd apps/ui-tars && pnpm run publish:mac-arm64
77+
- name: Save latest-mac-arm64.yml as an artifact
78+
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47
79+
with:
80+
name: latest-mac-${{ github.sha }}-arm64
81+
path: apps/ui-tars/out/latest-mac-arm64.yml
82+
if-no-files-found: error
83+
84+
publish_on_mac_x64:
85+
runs-on: macos-13
86+
steps:
87+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88+
- name: Show operating system info
89+
run: |
90+
echo "Operating System:"
91+
uname -a
92+
- name: Install pnpm
93+
run: npm install -g pnpm@9
94+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
95+
with:
96+
node-version: 20
97+
cache: 'pnpm'
98+
- name: Install Python setuptools
99+
run: brew install python-setuptools
100+
- name: Install appdmg
101+
run: npm install -g appdmg
102+
- name: Install the Apple certificate and provisioning profile
103+
env:
104+
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
105+
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
106+
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
107+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
108+
run: |
109+
# create variables
110+
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
111+
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
112+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
113+
114+
# import certificate and provisioning profile from secrets
115+
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
116+
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
117+
118+
# create temporary keychain
119+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
120+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
121+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
122+
123+
# import certificate to keychain
124+
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
125+
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
126+
security list-keychain -d user -s $KEYCHAIN_PATH
127+
128+
# apply provisioning profile
129+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
130+
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
131+
- name: install dependencies
132+
run: pnpm install
82133
- name: publish x64
83-
if: matrix.os == 'macos-13'
84134
env:
85135
APPLE_ID: ${{ secrets.APPLE_ID }}
86136
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
@@ -89,6 +139,46 @@ jobs:
89139
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90140
run: |
91141
cd apps/ui-tars && pnpm run publish:mac-x64
142+
- name: Save latest-mac-x64.yml as an artifact
143+
uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47
144+
with:
145+
name: latest-mac-${{ github.sha }}-x64
146+
path: apps/ui-tars/out/latest-mac-x64.yml
147+
if-no-files-found: error
148+
149+
merge-latest-mac:
150+
needs:
151+
- publish_on_mac
152+
- publish_on_mac_x64
153+
runs-on: ubuntu-latest
154+
steps:
155+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
156+
- name: Show operating system info
157+
run: |
158+
echo "Operating System:"
159+
uname -a
160+
- name: Install pnpm
161+
run: npm install -g pnpm@9
162+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
163+
with:
164+
node-version: 20
165+
cache: 'pnpm'
166+
- name: install dependencies
167+
run: pnpm i tsx js-yaml
168+
- name: Download All Artifacts
169+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e
170+
with:
171+
path: scripts/merge-yml
172+
pattern: latest-mac-${{ github.sha }}-*
173+
merge-multiple: true
174+
- name: merge mac-yaml
175+
run: |
176+
npx tsx ./scripts/merge-yml/merge-yml.ts && cat ./scripts/merge-yml/latest-mac.yml
177+
- name: Upload to Release
178+
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
179+
with:
180+
fail_on_unmatched_files: true
181+
files: ${{ github.workspace }}/scripts/merge-yml/latest-mac.yml
92182

93183
publish_on_win:
94184
runs-on: windows-latest

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ out
99
test-results/
1010
coverage/
1111
.turbo/
12+
scripts/merge-yml/*.yml

packages/common/electron-build/src/hooks/postMake.ts

+9
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ export const postMake: ForgeHookMap['postMake'] = async (
8585
lineWidth: -1,
8686
});
8787
fs.writeFileSync(ymlPath, ymlStr);
88+
// write yml to out/
89+
fs.writeFileSync(
90+
path.join(
91+
process.cwd(),
92+
'out',
93+
updateYmlMap[ymlKey as keyof typeof updateYmlMap],
94+
),
95+
ymlStr,
96+
);
8897

8998
makeResults.push({
9099
artifacts: [ymlPath],

scripts/merge-yml/merge-yml.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import yaml from 'js-yaml';
4+
5+
const cwd = path.join(__dirname);
6+
const x64Content = fs.readFileSync(
7+
path.join(cwd, './latest-mac-x64.yml'),
8+
'utf8',
9+
);
10+
const arm64Content = fs.readFileSync(
11+
path.join(cwd, './latest-mac-arm64.yml'),
12+
'utf8',
13+
);
14+
15+
interface YamlData {
16+
version?: string;
17+
files: {
18+
url: string;
19+
sha512: string;
20+
size: number;
21+
}[];
22+
releaseDate?: string;
23+
}
24+
25+
const x64Data = yaml.load(x64Content) as YamlData;
26+
const arm64Data = yaml.load(arm64Content) as YamlData;
27+
28+
// Merge files field from both x64 and arm64
29+
const mergedFiles = [...(x64Data.files || []), ...(arm64Data.files || [])];
30+
31+
// Combine other fields
32+
const combinedData = {
33+
version: x64Data.version || '0.0.0',
34+
files: mergedFiles,
35+
releaseDate: x64Data.releaseDate || '',
36+
};
37+
38+
const resultYaml = yaml.dump(combinedData, { lineWidth: 120 });
39+
40+
fs.writeFileSync(path.join(cwd, './latest-mac.yml'), resultYaml, 'utf8');

0 commit comments

Comments
 (0)