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