From 36bf2c8648815e528b6ffe01203100cebe53291c Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 12 Oct 2023 09:45:23 +0530 Subject: [PATCH] feat: snapcraft release support --- .github/workflows/release-snap.yml | 43 +++++++++++ package.json | 2 +- .../bruno-electron/electron-builder-config.js | 73 ++++++++----------- packages/bruno-electron/package.json | 1 + scripts/build-electron.sh | 7 +- 5 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/release-snap.yml diff --git a/.github/workflows/release-snap.yml b/.github/workflows/release-snap.yml new file mode 100644 index 000000000..b2b24ee89 --- /dev/null +++ b/.github/workflows/release-snap.yml @@ -0,0 +1,43 @@ +name: Publish to Snapcraft + +on: + workflow_dispatch: + inputs: + build: + description: 'Build and publish to Snapcraft' + required: true + default: 'true' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Check package-lock.json + run: npm ci + + - name: Install dependencies + run: npm install --legacy-peer-deps + + - name: Build Electron app + run: npm run build + + - name: Install Snapcraft + run: | + sudo snap install snapcraft --classic + continue-on-error: true + + - name: Configure Snapcraft + run: | + echo ${{ secrets.SNAPCRAFT_API_KEY }} | snapcraft login --with - + + - name: Publish to Snapcraft + run: | + snapcraft push packages/bruno-electron/out/*.snap --release stable diff --git a/package.json b/package.json index 9aaaf23f2..9778c1167 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dev:electron": "npm run dev --workspace=packages/bruno-electron", "build:bruno-query": "npm run build --workspace=packages/bruno-query", "build:graphql-docs": "npm run build --workspace=packages/bruno-graphql-docs", - "build:electron": "./scripts/build-electron.sh", + "build:electron:snap": "./scripts/build-electron.sh snap", "test:e2e": "npx playwright test", "test:report": "npx playwright show-report", "prepare": "husky install" diff --git a/packages/bruno-electron/electron-builder-config.js b/packages/bruno-electron/electron-builder-config.js index f7b1c5abc..5320c1895 100644 --- a/packages/bruno-electron/electron-builder-config.js +++ b/packages/bruno-electron/electron-builder-config.js @@ -1,56 +1,45 @@ require('dotenv').config({ path: process.env.DOTENV_PATH }); const config = { - "appId": "com.usebruno.app", - "productName": "Bruno", - "electronVersion": "21.1.1", - "directories": { - "buildResources": "resources", - "output": "out" + appId: 'com.usebruno.app', + productName: 'Bruno', + electronVersion: '21.1.1', + directories: { + buildResources: 'resources', + output: 'out' }, - "files": [ - "**/*" - ], - "afterSign": "notarize.js", - "mac": { - "artifactName": "${name}_${version}_${arch}_${os}.${ext}", - "category": "public.app-category.developer-tools", - "target": [ + files: ['**/*'], + afterSign: 'notarize.js', + mac: { + artifactName: '${name}_${version}_${arch}_${os}.${ext}', + category: 'public.app-category.developer-tools', + target: [ { - "target": "dmg", - "arch": [ - "x64", - "arm64" - ] + target: 'dmg', + arch: ['x64', 'arm64'] }, { - "target": "zip", - "arch": [ - "x64", - "arm64" - ] + target: 'zip', + arch: ['x64', 'arm64'] } ], - "icon": "resources/icons/mac/icon.icns", - "hardenedRuntime": true, - "identity": "Anoop MD (W7LPPWA48L)", - "entitlements": "resources/entitlements.mac.plist", - "entitlementsInherit": "resources/entitlements.mac.plist" + icon: 'resources/icons/mac/icon.icns', + hardenedRuntime: true, + identity: 'Anoop MD (W7LPPWA48L)', + entitlements: 'resources/entitlements.mac.plist', + entitlementsInherit: 'resources/entitlements.mac.plist' }, - "linux": { - "artifactName": "${name}_${version}_${arch}_linux.${ext}", - "icon": "resources/icons/png", - "target": [ - "AppImage", - "deb" - ] + linux: { + artifactName: '${name}_${version}_${arch}_linux.${ext}', + icon: 'resources/icons/png', + target: ['AppImage', 'deb', 'snap'] }, - "win": { - "artifactName": "${name}_${version}_${arch}_win.${ext}", - "icon": "resources/icons/png", - "certificateFile": `${process.env.WIN_CERT_FILEPATH}`, - "certificatePassword": `${process.env.WIN_CERT_PASSWORD}`, + win: { + artifactName: '${name}_${version}_${arch}_win.${ext}', + icon: 'resources/icons/png', + certificateFile: `${process.env.WIN_CERT_FILEPATH}`, + certificatePassword: `${process.env.WIN_CERT_PASSWORD}` } }; -module.exports = config; \ No newline at end of file +module.exports = config; diff --git a/packages/bruno-electron/package.json b/packages/bruno-electron/package.json index 95c1086fa..cedd5df60 100644 --- a/packages/bruno-electron/package.json +++ b/packages/bruno-electron/package.json @@ -10,6 +10,7 @@ "clean": "rimraf dist", "dev": "electron .", "dist": "electron-builder --mac --config electron-builder-config.js", + "dist:snap": "electron-builder --linux snap --config electron-builder-config.js", "pack": "electron-builder --dir", "test": "jest" }, diff --git a/scripts/build-electron.sh b/scripts/build-electron.sh index 719a0c593..a56b3bcc4 100755 --- a/scripts/build-electron.sh +++ b/scripts/build-electron.sh @@ -19,4 +19,9 @@ sed -i'' -e 's@/_next/@_next/@g' packages/bruno-electron/web/**.html # Remove sourcemaps find packages/bruno-electron/web -name '*.map' -type f -delete -npm run dist --workspace=packages/bruno-electron \ No newline at end of file +if [ "$1" == "snap" ]; then + echo "Building snap distribution" + npm run dist:snap --workspace=packages/bruno-electron +else + echo "Please pass a build distribution type" +fi \ No newline at end of file