Skip to content

Commit 0e29040

Browse files
authored
[CI] Fix macOS release workflow (#755)
* ci: write separate yml files for mac release * ci: try to join files * Update artifact download and extraction in release_macOS workflow * Refactor artifact download paths in release_macOS workflow * Add file and subdirectory listing and show latest-mac.yml * Update release_macOS.yml to append content from x64 and arm64 files * Merge YML files to create latest-mac.yml using node script * Update file path in merge-yml.js * Add Node.js setup, configure git for HTTP authentication, authenticate with private NPM package, and install dependencies * chore: PR comments --------- Co-authored-by: Flavio F Lima <flavioislima@users.noreply.github.com>
1 parent 0914d17 commit 0e29040

File tree

3 files changed

+101
-5
lines changed

3 files changed

+101
-5
lines changed

.github/workflows/release_macOS.yml

+76-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up Node.js
3131
uses: actions/setup-node@v3
3232
with:
33-
node-version: '18'
33+
node-version: 'latest'
3434
cache: 'yarn'
3535

3636
- name: Reconfigure git to use HTTP authentication
@@ -51,21 +51,31 @@ jobs:
5151
run: yarn release:mac:x64
5252
env:
5353
NOTARIZE: true
54+
- name: Copy dist/latest-mac.yml to dist/latest-mac-x64.yml
55+
run: |
56+
cp dist/latest-mac.yml dist/latest-mac-x64.yml
57+
shell: bash
58+
- name: Save latest-mac-x64.yml as an artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: latest-mac-x64
62+
path: dist/latest-mac-x64.yml
63+
if-no-files-found: error
5464

5565
release-arm64:
5666
runs-on: macos-latest-xlarge
5767

5868
steps:
5969
- name: Checkout code
60-
uses: actions/checkout@v3
70+
uses: actions/checkout@v4
6171
with:
6272
submodules: 'recursive'
6373
token: ${{ secrets.pat }}
6474

6575
- name: Set up Node.js
66-
uses: actions/setup-node@v3
76+
uses: actions/setup-node@v4
6777
with:
68-
node-version: '18'
78+
node-version: 'latest'
6979
cache: 'yarn'
7080

7181
- name: Reconfigure git to use HTTP authentication
@@ -86,3 +96,65 @@ jobs:
8696
run: yarn release:mac:arm64
8797
env:
8898
NOTARIZE: true
99+
- name: Copy dist/latest-mac.yml to dist/latest-mac-arm64.yml
100+
run: |
101+
cp dist/latest-mac.yml dist/latest-mac-arm64.yml
102+
shell: bash
103+
- name: Save latest-mac-arm64.yml as an artifact
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: latest-mac-arm64
107+
path: dist/latest-mac-arm64.yml
108+
if-no-files-found: error
109+
110+
generate-latest-mac:
111+
needs:
112+
- release-x64
113+
- release-arm64
114+
runs-on: ubuntu-latest
115+
116+
steps:
117+
- name: Checkout code
118+
uses: actions/checkout@v4
119+
120+
- name: Set up Node.js
121+
uses: actions/setup-node@v4
122+
with:
123+
node-version: 'latest'
124+
cache: 'yarn'
125+
126+
- name: Reconfigure git to use HTTP authentication
127+
run: >
128+
git config --global url."https://github.com/".insteadOf
129+
ssh://git@github.com/
130+
131+
- name: Authenticate with private NPM package
132+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
133+
134+
- name: Install dependencies
135+
run: yarn setup
136+
137+
- name: Download artifacts from release-x64 and release-arm64 jobs
138+
uses: actions/download-artifact@v4
139+
with:
140+
name: latest-mac-x64
141+
path: dist-x64
142+
143+
- uses: actions/download-artifact@v4
144+
with:
145+
name: latest-mac-arm64
146+
path: dist-arm64
147+
148+
- name: Merge YMLs
149+
run: |
150+
yarn add js-yaml
151+
node merge-yml.js
152+
working-directory: ${{ github.workspace }}
153+
154+
- name: Update draft with latest-mac.yml
155+
uses: ncipollo/release-action@v1.13.0
156+
with:
157+
token: ${{ secrets.WORKFLOW_TOKEN }}
158+
draft: true
159+
allowUpdates: true
160+
artifacts: latest-mac.yml

merge-yml.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs')
2+
const yaml = require('js-yaml')
3+
4+
const x64Content = fs.readFileSync('dist-x64/latest-mac-x64.yml', 'utf8')
5+
const arm64Content = fs.readFileSync('dist-arm64/latest-mac-arm64.yml', 'utf8')
6+
7+
const x64Data = yaml.load(x64Content)
8+
const arm64Data = yaml.load(arm64Content)
9+
10+
// Merge files field from both x64 and arm64
11+
const mergedFiles = [...(x64Data.files || []), ...(arm64Data.files || [])]
12+
13+
// Combine other fields
14+
const combinedData = {
15+
version: x64Data.version || '0.0.0',
16+
files: mergedFiles,
17+
path: x64Data.path || '',
18+
sha512: x64Data.sha512 || '',
19+
releaseDate: x64Data.releaseDate || ''
20+
}
21+
22+
const resultYaml = yaml.dump(combinedData, { lineWidth: 120 })
23+
24+
fs.writeFileSync('latest-mac.yml', resultYaml, 'utf8')

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hyperplay",
3-
"version": "0.11.3",
3+
"version": "0.11.4",
44
"private": true,
55
"main": "build/electron/main.js",
66
"homepage": "./",

0 commit comments

Comments
 (0)