Optimize CI build: npm/electron caches, merged prepare job, wine64-only, store compression
- Cache ~/.npm (setup-node) and ~/.cache/electron{,-builder} between runs
- Merge increment-version + prepare-release into one job; build jobs check out
the bumped commit directly instead of pulling
- Install wine64 only (drop i386 arch + wine32)
- Shallow checkouts in build jobs; drop no-op clean step
- Fix GITHUB_TOKEN/GITEA_TOKEN mixup in finalize-release tag cleanup
- NSIS compression: store (faster, larger exe)
- Bump cinny submodule: sourcemap skipped in CI
This commit is contained in:
1 parent
cb4445f812
commit
7821c23878
3 files changed
+62
-78
No files matched your search
+60
-76
@@ -12,10 +12,12 @@ on:
|
||||
# Build jobs publish assets straight to Gitea/GitHub releases via the REST API.
|
||||
|
||||
jobs:
|
||||
increment-version:
|
||||
prepare:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.finalize.outputs.VERSION }}
|
||||
tag: ${{ steps.finalize.outputs.TAG_NAME }}
|
||||
commit_sha: ${{ steps.finalize.outputs.COMMIT_SHA }}
|
||||
should_build: ${{ steps.decide.outputs.SHOULD_BUILD }}
|
||||
|
||||
steps:
|
||||
@@ -52,7 +54,7 @@ jobs:
|
||||
|
||||
- name: Bump patch version
|
||||
id: bump
|
||||
if: ${{ steps.decide.outputs.SHOULD_BUMP == 'true' }}
|
||||
if: steps.decide.outputs.SHOULD_BUILD == 'true' && steps.decide.outputs.SHOULD_BUMP == 'true'
|
||||
run: |
|
||||
# Get current version from package.json
|
||||
CURRENT=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
||||
@@ -75,7 +77,7 @@ jobs:
|
||||
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Commit and push version bump
|
||||
if: ${{ steps.decide.outputs.SHOULD_BUMP == 'true' }}
|
||||
if: steps.decide.outputs.SHOULD_BUILD == 'true' && steps.decide.outputs.SHOULD_BUMP == 'true'
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
@@ -99,50 +101,24 @@ jobs:
|
||||
echo "Failed to push version bump after 3 attempts"
|
||||
exit 1
|
||||
|
||||
- name: Finalize version output
|
||||
- name: Resolve version and commit
|
||||
id: finalize
|
||||
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||
run: |
|
||||
if [ -n "${{ steps.bump.outputs.VERSION }}" ]; then
|
||||
echo "VERSION=${{ steps.bump.outputs.VERSION }}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "VERSION=${{ steps.decide.outputs.CURRENT_VERSION }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
prepare-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: increment-version
|
||||
if: always() && needs.increment-version.outputs.should_build == 'true'
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.VERSION }}
|
||||
tag: ${{ steps.version.outputs.TAG_NAME }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.ref_name }}
|
||||
|
||||
- name: Pull latest (after version bump)
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: git pull origin main
|
||||
|
||||
- name: Resolve version
|
||||
id: version
|
||||
run: |
|
||||
if [ -n "${{ needs.increment-version.outputs.version }}" ]; then
|
||||
VERSION="${{ needs.increment-version.outputs.version }}"
|
||||
VERSION="${{ steps.bump.outputs.VERSION }}"
|
||||
else
|
||||
VERSION=$(grep -Po '"version":\s*"\K[^"]+' package.json | head -1)
|
||||
fi
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "TAG_NAME=v$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "Version: $VERSION"
|
||||
|
||||
- name: Create and push tag
|
||||
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
TAG_NAME="${{ steps.finalize.outputs.TAG_NAME }}"
|
||||
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
||||
echo "Tag $TAG_NAME already exists"
|
||||
else
|
||||
@@ -153,12 +129,13 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Ensure Gitea release
|
||||
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
VERSION="${{ steps.finalize.outputs.VERSION }}"
|
||||
TAG_NAME="${{ steps.finalize.outputs.TAG_NAME }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
@@ -177,12 +154,13 @@ jobs:
|
||||
echo "Gitea release id: ${RELEASE_ID}"
|
||||
|
||||
- name: Ensure GitHub release
|
||||
if: steps.decide.outputs.SHOULD_BUILD == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
TAG_NAME="v${VERSION}"
|
||||
VERSION="${{ steps.finalize.outputs.VERSION }}"
|
||||
TAG_NAME="${{ steps.finalize.outputs.TAG_NAME }}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||
|
||||
RELEASE_ID=$(curl -fsS -H "Authorization: token ${GH_TOKEN}" \
|
||||
@@ -201,15 +179,16 @@ jobs:
|
||||
|
||||
build-windows:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [increment-version, prepare-release]
|
||||
if: always() && needs.prepare-release.result == 'success'
|
||||
needs: prepare
|
||||
if: always() && needs.prepare.result == 'success' && needs.prepare.outputs.should_build == 'true'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
ref: ${{ github.ref_name }}
|
||||
fetch-depth: 1
|
||||
ref: ${{ needs.prepare.outputs.commit_sha }}
|
||||
|
||||
- name: Checkout submodules manually
|
||||
run: |
|
||||
@@ -239,26 +218,30 @@ jobs:
|
||||
echo "Resolved submodule commit:"
|
||||
git -C cinny rev-parse HEAD
|
||||
|
||||
- name: Pull latest (after version bump)
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: git pull origin main
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
cinny/package-lock.json
|
||||
|
||||
- name: Cache Electron downloads
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/electron
|
||||
~/.cache/electron-builder
|
||||
key: electron-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: electron-
|
||||
|
||||
- name: Install Wine (NSIS cross-build)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# electron-builder spawns `wine` by name; wine64 alone is not enough.
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
wine \
|
||||
wine64 \
|
||||
wine32 \
|
||||
|| sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends wine64
|
||||
# electron-builder spawns `wine` by name; wine64 alone is enough, wine32
|
||||
# only adds a slow i386 package index for no benefit here.
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends wine64
|
||||
|
||||
if ! command -v wine >/dev/null 2>&1; then
|
||||
WINE64_BIN=$(command -v wine64)
|
||||
@@ -276,10 +259,6 @@ jobs:
|
||||
working-directory: ./cinny
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
- name: Clean previous builds
|
||||
run: |
|
||||
rm -rf cinny/dist dist-electron
|
||||
|
||||
- name: Build Electron app
|
||||
run: npm run build:local -- --win
|
||||
env:
|
||||
@@ -292,7 +271,7 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||
@@ -356,15 +335,16 @@ jobs:
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [increment-version, prepare-release]
|
||||
if: always() && needs.prepare-release.result == 'success'
|
||||
needs: prepare
|
||||
if: always() && needs.prepare.result == 'success' && needs.prepare.outputs.should_build == 'true'
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
ref: ${{ github.ref_name }}
|
||||
fetch-depth: 1
|
||||
ref: ${{ needs.prepare.outputs.commit_sha }}
|
||||
|
||||
- name: Checkout submodules manually
|
||||
run: |
|
||||
@@ -394,14 +374,23 @@ jobs:
|
||||
echo "Resolved submodule commit:"
|
||||
git -C cinny rev-parse HEAD
|
||||
|
||||
- name: Pull latest (after version bump)
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: git pull origin main
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: |
|
||||
package-lock.json
|
||||
cinny/package-lock.json
|
||||
|
||||
- name: Cache Electron downloads
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/electron
|
||||
~/.cache/electron-builder
|
||||
key: electron-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: electron-
|
||||
|
||||
- name: Install dependencies (root)
|
||||
run: npm ci --prefer-offline
|
||||
@@ -410,10 +399,6 @@ jobs:
|
||||
working-directory: ./cinny
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
- name: Clean previous builds
|
||||
run: |
|
||||
rm -rf cinny/dist dist-electron
|
||||
|
||||
- name: Build Electron app
|
||||
run: npm run build:local -- --linux
|
||||
env:
|
||||
@@ -425,8 +410,7 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION="${{ needs.prepare-release.outputs.version }}"
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||
@@ -486,8 +470,8 @@ jobs:
|
||||
|
||||
finalize-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [increment-version, prepare-release, build-windows, build-linux]
|
||||
if: always() && needs.prepare-release.result == 'success' && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
|
||||
needs: [prepare, build-windows, build-linux]
|
||||
if: always() && needs.prepare.result == 'success' && needs.prepare.outputs.should_build == 'true' && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
|
||||
|
||||
steps:
|
||||
- name: Cleanup old Gitea releases
|
||||
@@ -495,7 +479,7 @@ jobs:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||
API_BASE="${{ github.server_url }}/api/v1"
|
||||
REPO="${{ github.repository }}"
|
||||
|
||||
@@ -521,7 +505,7 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GHTOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG_NAME="${{ needs.prepare-release.outputs.tag }}"
|
||||
TAG_NAME="${{ needs.prepare.outputs.tag }}"
|
||||
GITHUB_REPO="Paarrot/Paarrot-Desktop"
|
||||
|
||||
echo "Cleaning up old GitHub releases (keeping ${TAG_NAME})..."
|
||||
|
||||
+1
-1
Submodule cinny updated: 72c71bc789...fabbbc40af.
@@ -102,7 +102,7 @@
|
||||
"shortcutName": "Paarrot",
|
||||
"differentialPackage": false
|
||||
},
|
||||
"compression": "normal",
|
||||
"compression": "store",
|
||||
"publish": [
|
||||
{
|
||||
"provider": "github",
|
||||
|
||||
Reference in new issue
Block a user