Skip to content

Commit d864d3e

Browse files
committed
workflow and verify assets updated by copilot
1 parent f9304c8 commit d864d3e

File tree

1 file changed

+87
-31
lines changed

1 file changed

+87
-31
lines changed

.github/workflows/release.yml

Lines changed: 87 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Need to write to repo contents to upload the app to GitHub Release
2-
# See: https://www.electronforge.io/config/publishers/github#authentication
31
permissions:
42
contents: write
53

@@ -8,49 +6,108 @@ on:
86
workflow_dispatch:
97
push:
108
branches: [main, release/**]
9+
1110
jobs:
1211
build:
1312
environment: release
1413
permissions:
1514
contents: write
1615
strategy:
17-
# Uncomment max-parallel to prevent race condition (where multiple releases are
18-
# created concurrently). Typically though, we'll create a release manually ahead of time
19-
# which prevents the race.
20-
# max-parallel: 1
2116
matrix:
22-
# See https://github.com/SFARPak/dyad/issues/96
17+
# Use the recommended minimum runner images to ensure compatibility:
18+
# - ubuntu: ubuntu-22.04
19+
# - windows: windows-2022
20+
# - macOS: macos-13 (minimum supported macOS runner)
2321
os:
24-
[
25-
{ name: "windows", image: "windows-latest" },
26-
{ name: "linux", image: "ubuntu-22.04" },
27-
{ name: "macos-intel", image: "macos-13" },
28-
{ name: "macos", image: "macos-latest" },
29-
]
22+
- { name: "windows", image: "windows-2022" }
23+
- { name: "linux", image: "ubuntu-22.04" }
24+
- { name: "macos-intel", image: "macos-13" }
25+
- { name: "macos", image: "macos-13" }
3026
runs-on: ${{ matrix.os.image }}
27+
env:
28+
CI: true
29+
3130
steps:
3231
- name: Github checkout
3332
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33+
3434
- name: Use Node.js
3535
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
3636
with:
3737
node-version: 20
38-
- name: Clean up
38+
cache: 'npm'
39+
40+
# Ensure npm cache dir exists on Windows so actions/cache doesn't fail
41+
- name: Ensure npm cache directory exists (Windows)
42+
if: runner.os == 'Windows'
43+
run: |
44+
powershell -Command "New-Item -Path 'C:\npm\cache' -ItemType Directory -Force | Out-Null"
45+
46+
- name: Cache npm cache and node_modules
47+
uses: actions/cache@v4
48+
with:
49+
path: |
50+
${{ runner.os == 'Windows' && 'C:\\npm\\cache' || '~/.npm' }}
51+
node_modules
52+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
53+
restore-keys: |
54+
${{ runner.os }}-node-
55+
56+
# CI-only cleanup to avoid npm optional deps corruption (runner-local only)
57+
- name: Clean up potential corrupted install (CI-only)
58+
run: |
59+
if [ "${{ runner.os }}" = "Windows" ]; then
60+
echo "Removing node_modules and package-lock.json (runner-only)"
61+
powershell -Command "if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules } ; if (Test-Path package-lock.json) { Remove-Item -Force package-lock.json }"
62+
else
63+
rm -rf node_modules package-lock.json || true
64+
fi
65+
shell: bash
66+
67+
- name: Configure npm for CI (cache path + disable optional deps)
68+
run: |
69+
if [ "${{ runner.os }}" = "Windows" ]; then
70+
npm config set cache "C:\\npm\\cache" --global
71+
else
72+
npm config set cache "${HOME}/.npm" --global
73+
fi
74+
# Disable optional deps in CI to avoid failing native optional installs (workaround).
75+
npm config set optional false --global
76+
shell: bash
77+
78+
- name: Install dependencies (npm ci || npm install fallback)
79+
run: |
80+
set -e
81+
echo "Attempting npm ci for reproducible install..."
82+
if [ "${{ runner.os }}" = "Windows" ]; then
83+
npm ci --no-audit --prefer-offline || (powershell -Command "if (Test-Path package-lock.json) { Remove-Item -Force package-lock.json }" ; npm install --no-audit --prefer-offline)
84+
else
85+
npm ci --no-audit --prefer-offline || (rm -f package-lock.json && npm install --no-audit --prefer-offline)
86+
fi
87+
shell: bash
88+
89+
# Try platform-specific native rebuilds if present; non-fatal
90+
- name: Try rebuild rollup native binary (non-fatal)
3991
run: |
40-
rm -rf node_modules
41-
rm -f package-lock.json
42-
npm cache clean --force
92+
set -e || true
93+
if [[ "${{ matrix.os.name }}" == "linux" ]]; then
94+
npm rebuild @rollup/rollup-linux-x64-gnu || true
95+
elif [[ "${{ matrix.os.name }}" == "macos-intel" ]]; then
96+
npm rebuild @rollup/rollup-darwin-x64 || true
97+
elif [[ "${{ matrix.os.name }}" == "macos" ]]; then
98+
npm rebuild @rollup/rollup-darwin-arm64 || true
99+
elif [[ "${{ matrix.os.name }}" == "windows" ]]; then
100+
npm rebuild @rollup/rollup-win32-x64-msvc || true
101+
fi
43102
shell: bash
44-
- run: npm install --include=optional
45-
- run: npm rebuild @rollup/rollup-linux-x64-gnu || true
46-
if: contains(matrix.os.name, 'linux')
47-
- run: npm rebuild @rollup/rollup-darwin-x64 || true
48-
if: contains(matrix.os.name, 'macos-intel')
49-
- run: npm rebuild @rollup/rollup-darwin-arm64 || true
50-
if: contains(matrix.os.name, 'macos')
51-
- run: npm rebuild @rollup/rollup-win32-x64-msvc || true
52-
if: contains(matrix.os.name, 'windows')
53-
# Publish (all platforms)
103+
104+
- name: Build
105+
env:
106+
NODE_OPTIONS: "--max-old-space-size=4096"
107+
run: |
108+
npm run build
109+
shell: bash
110+
54111
- name: Publish app
55112
env:
56113
NODE_OPTIONS: "--max-old-space-size=4096"
@@ -66,21 +123,18 @@ jobs:
66123
shell: bash
67124

68125
- name: Wait for GitHub to register release uploads
69-
# Some publishers upload files asynchronously; wait and then list assets
70126
env:
71127
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72128
run: |
73129
set -e
74130
VERSION=$(node -e "console.log(require('./package.json').version)")
75131
TAG="v${VERSION}"
76132
echo "Waiting for GitHub to register release ${TAG} assets..."
77-
# Poll releases/tags endpoint for up to 90s (9 attempts)
78133
attempts=0
79134
max=9
80135
sleep_interval=10
81136
while [ $attempts -lt $max ]; do
82137
echo "Attempt $((attempts+1))/${max}..."
83-
# Use the tag endpoint to retrieve the release by tag
84138
resp=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/releases/tags/${TAG}" || true)
85139
if echo "$resp" | grep -q "\"message\": \"Not Found\""; then
86140
echo "Release ${TAG} not found yet."
@@ -108,7 +162,7 @@ jobs:
108162
verify-assets:
109163
name: Verify Release Assets
110164
needs: build
111-
runs-on: ubuntu-latest
165+
runs-on: ubuntu-22.04
112166
permissions:
113167
contents: read
114168
packages: read
@@ -117,10 +171,12 @@ jobs:
117171
steps:
118172
- name: Github checkout
119173
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
174+
120175
- name: Use Node.js
121176
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
122177
with:
123178
node-version: 20
179+
124180
- name: Verify all release assets are uploaded
125181
env:
126182
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)