feat: snapcraft release support

This commit is contained in:
Anoop M D 2023-10-12 09:45:23 +05:30
parent 36caa5c2d3
commit 36bf2c8648
5 changed files with 82 additions and 44 deletions

43
.github/workflows/release-snap.yml vendored Normal file
View File

@ -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

View File

@ -31,7 +31,7 @@
"dev:electron": "npm run dev --workspace=packages/bruno-electron", "dev:electron": "npm run dev --workspace=packages/bruno-electron",
"build:bruno-query": "npm run build --workspace=packages/bruno-query", "build:bruno-query": "npm run build --workspace=packages/bruno-query",
"build:graphql-docs": "npm run build --workspace=packages/bruno-graphql-docs", "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:e2e": "npx playwright test",
"test:report": "npx playwright show-report", "test:report": "npx playwright show-report",
"prepare": "husky install" "prepare": "husky install"

View File

@ -1,55 +1,44 @@
require('dotenv').config({ path: process.env.DOTENV_PATH }); require('dotenv').config({ path: process.env.DOTENV_PATH });
const config = { const config = {
"appId": "com.usebruno.app", appId: 'com.usebruno.app',
"productName": "Bruno", productName: 'Bruno',
"electronVersion": "21.1.1", electronVersion: '21.1.1',
"directories": { directories: {
"buildResources": "resources", buildResources: 'resources',
"output": "out" output: 'out'
}, },
"files": [ files: ['**/*'],
"**/*" afterSign: 'notarize.js',
], mac: {
"afterSign": "notarize.js", artifactName: '${name}_${version}_${arch}_${os}.${ext}',
"mac": { category: 'public.app-category.developer-tools',
"artifactName": "${name}_${version}_${arch}_${os}.${ext}", target: [
"category": "public.app-category.developer-tools",
"target": [
{ {
"target": "dmg", target: 'dmg',
"arch": [ arch: ['x64', 'arm64']
"x64",
"arm64"
]
}, },
{ {
"target": "zip", target: 'zip',
"arch": [ arch: ['x64', 'arm64']
"x64",
"arm64"
]
} }
], ],
"icon": "resources/icons/mac/icon.icns", icon: 'resources/icons/mac/icon.icns',
"hardenedRuntime": true, hardenedRuntime: true,
"identity": "Anoop MD (W7LPPWA48L)", identity: 'Anoop MD (W7LPPWA48L)',
"entitlements": "resources/entitlements.mac.plist", entitlements: 'resources/entitlements.mac.plist',
"entitlementsInherit": "resources/entitlements.mac.plist" entitlementsInherit: 'resources/entitlements.mac.plist'
}, },
"linux": { linux: {
"artifactName": "${name}_${version}_${arch}_linux.${ext}", artifactName: '${name}_${version}_${arch}_linux.${ext}',
"icon": "resources/icons/png", icon: 'resources/icons/png',
"target": [ target: ['AppImage', 'deb', 'snap']
"AppImage",
"deb"
]
}, },
"win": { win: {
"artifactName": "${name}_${version}_${arch}_win.${ext}", artifactName: '${name}_${version}_${arch}_win.${ext}',
"icon": "resources/icons/png", icon: 'resources/icons/png',
"certificateFile": `${process.env.WIN_CERT_FILEPATH}`, certificateFile: `${process.env.WIN_CERT_FILEPATH}`,
"certificatePassword": `${process.env.WIN_CERT_PASSWORD}`, certificatePassword: `${process.env.WIN_CERT_PASSWORD}`
} }
}; };

View File

@ -10,6 +10,7 @@
"clean": "rimraf dist", "clean": "rimraf dist",
"dev": "electron .", "dev": "electron .",
"dist": "electron-builder --mac --config electron-builder-config.js", "dist": "electron-builder --mac --config electron-builder-config.js",
"dist:snap": "electron-builder --linux snap --config electron-builder-config.js",
"pack": "electron-builder --dir", "pack": "electron-builder --dir",
"test": "jest" "test": "jest"
}, },

View File

@ -19,4 +19,9 @@ sed -i'' -e 's@/_next/@_next/@g' packages/bruno-electron/web/**.html
# Remove sourcemaps # Remove sourcemaps
find packages/bruno-electron/web -name '*.map' -type f -delete find packages/bruno-electron/web -name '*.map' -type f -delete
npm run dist --workspace=packages/bruno-electron 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