fix(ci): add electronDist, validate artifacts before release
Build and Release / build-and-release (push) Failing after 2m39s
Build and Release / build-and-release (push) Failing after 2m39s
electron-builder couldn't resolve the Electron binary from the electron-nightly npm alias, producing no output. Add explicit electronDist to electron-builder.yml and validate artifacts exist before creating the GitHub release to prevent empty releases.
This commit is contained in:
@@ -18,18 +18,14 @@ jobs:
|
|||||||
- name: Check if version already released
|
- name: Check if version already released
|
||||||
id: version-check
|
id: version-check
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/')
|
VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/')
|
||||||
TAG="v$VERSION"
|
TAG="v$VERSION"
|
||||||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
|
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
|
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
||||||
-H "Authorization: Bearer $GITHUB_TOKEN" \
|
|
||||||
"https://api.github.com/repos/${{ github.repository }}/releases/tags/$TAG")
|
|
||||||
|
|
||||||
if [ "$STATUS" = "200" ]; then
|
|
||||||
echo "Release $TAG already exists, skipping build"
|
echo "Release $TAG already exists, skipping build"
|
||||||
echo "SKIP=true" >> "$GITHUB_OUTPUT"
|
echo "SKIP=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
@@ -43,26 +39,35 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '22'
|
||||||
|
|
||||||
- name: Install Wine (for Windows cross-compilation)
|
- name: Install system dependencies
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
run: |
|
run: |
|
||||||
sudo dpkg --add-architecture i386
|
sudo dpkg --add-architecture i386
|
||||||
sudo mkdir -pm755 /etc/apt/keyrings
|
|
||||||
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
|
|
||||||
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/$(lsb_release -cs)/winehq-$(lsb_release -cs).sources
|
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -y --install-recommends winehq-stable
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
wine wine32 wine64 \
|
||||||
|
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2t64 \
|
||||||
|
libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
|
||||||
|
libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 \
|
||||||
|
libcairo2 libasound2t64 libgtk-3-0
|
||||||
WINEDEBUG=-all wine wineboot --init || true
|
WINEDEBUG=-all wine wineboot --init || true
|
||||||
wine --version
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
run: npm ci
|
run: npm ci --legacy-peer-deps
|
||||||
|
|
||||||
- name: Build source
|
- name: Build source
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Verify Electron binaries
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
run: |
|
||||||
|
echo "=== Electron dist (stock, for Linux build) ==="
|
||||||
|
ls node_modules/electron/dist/electron 2>/dev/null && echo "OK" || echo "MISSING"
|
||||||
|
echo "=== Electron dist-win (patched, for Windows build) ==="
|
||||||
|
ls node_modules/electron/dist-win/electron.exe 2>/dev/null && echo "OK" || echo "MISSING"
|
||||||
|
|
||||||
- name: Build Windows distributables
|
- name: Build Windows distributables
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
env:
|
env:
|
||||||
@@ -73,60 +78,35 @@ jobs:
|
|||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
run: npx electron-builder --linux --publish never
|
run: npx electron-builder --linux --publish never
|
||||||
|
|
||||||
- name: List build output
|
- name: Report build sizes
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
run: |
|
run: |
|
||||||
echo "=== Build output ==="
|
echo "=== Build output sizes ==="
|
||||||
ls -lh out/ 2>/dev/null || echo "No out/ directory"
|
ls -lh out/*.exe out/*.AppImage out/*.deb 2>/dev/null || true
|
||||||
|
|
||||||
- name: Create release and upload assets
|
- name: Create GitHub release and upload assets
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAG: ${{ steps.version-check.outputs.TAG }}
|
|
||||||
run: |
|
run: |
|
||||||
API="https://api.github.com/repos/${{ github.repository }}"
|
# Collect built artifacts
|
||||||
AUTH="Authorization: Bearer $GITHUB_TOKEN"
|
ASSETS=()
|
||||||
|
for file in out/*.exe out/*.AppImage out/*.deb; do
|
||||||
|
[ -f "$file" ] || continue
|
||||||
|
ASSETS+=("$file")
|
||||||
|
done
|
||||||
|
|
||||||
# Create release
|
if [ ${#ASSETS[@]} -eq 0 ]; then
|
||||||
RESPONSE=$(curl -s -X POST "$API/releases" \
|
echo "ERROR: No build artifacts found in out/"
|
||||||
-H "$AUTH" \
|
ls -la out/ 2>/dev/null || echo "out/ directory does not exist"
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"$TAG\",
|
|
||||||
\"name\": \"$TAG\",
|
|
||||||
\"body\": \"Automated build for $TAG\",
|
|
||||||
\"draft\": false,
|
|
||||||
\"prerelease\": false
|
|
||||||
}")
|
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
|
||||||
UPLOAD_URL=$(echo "$RESPONSE" | jq -r '.upload_url' | sed 's/{?name,label}//')
|
|
||||||
echo "Created release ID: $RELEASE_ID"
|
|
||||||
|
|
||||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "Failed to create release:"
|
|
||||||
echo "$RESPONSE"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Upload all built artifacts
|
echo "Uploading ${#ASSETS[@]} assets:"
|
||||||
UPLOADED=0
|
printf ' %s\n' "${ASSETS[@]}"
|
||||||
for file in out/*.exe out/*.AppImage out/*.deb; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
FILENAME=$(basename "$file")
|
|
||||||
echo "Uploading: $FILENAME ($(du -h "$file" | cut -f1))"
|
|
||||||
curl -s -X POST "${UPLOAD_URL}?name=${FILENAME}" \
|
|
||||||
-H "$AUTH" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@$file" \
|
|
||||||
| jq -r '" -> \(.name) (\(.size) bytes)"'
|
|
||||||
UPLOADED=$((UPLOADED + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$UPLOADED" -eq 0 ]; then
|
gh release create "${{ steps.version-check.outputs.TAG }}" \
|
||||||
echo "WARNING: No artifacts found in out/"
|
--repo "$GITHUB_REPOSITORY" \
|
||||||
ls -la out/ 2>/dev/null || true
|
--title "${{ steps.version-check.outputs.TAG }}" \
|
||||||
fi
|
--notes "Automated build for ${{ steps.version-check.outputs.TAG }}" \
|
||||||
|
"${ASSETS[@]}"
|
||||||
echo "Uploaded $UPLOADED assets"
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
appId: com.krunkercivilian.client
|
appId: com.krunkercivilian.client
|
||||||
productName: Krunker Civilian Client
|
productName: Krunker Civilian Client
|
||||||
|
electronDist: node_modules/electron/dist
|
||||||
directories:
|
directories:
|
||||||
output: out
|
output: out
|
||||||
buildResources: build
|
buildResources: build
|
||||||
|
|||||||
Reference in New Issue
Block a user