Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release
on:
push:
branches:
- 60-configure-release-pipeline

jobs:
release:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPABASE_URL: ${{ vars.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ vars.SUPABASE_ANON_KEY }}
run: npm i

- name: Bump version
if: matrix.os == 'macos-latest'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
npm run version:bump
npm install --package-lock-only
cd release/app && npm install --package-lock-only && cd ../..
git add package.json package-lock.json release/app/package.json release/app/package-lock.json
git commit -m "chore: bump version [skip ci]"
git tag "v$(node -p "require('./package.json').version")"
git push --follow-tags

- name: Build and release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPABASE_URL: ${{ vars.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ vars.SUPABASE_ANON_KEY }}
run: |
npm run package
npm run release
3 changes: 2 additions & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ directories:
app: release/app
buildResources: assets
output: release/build
extraResources: # copy the file or directory with matching names directly into the apps resources directory (Contents/Resources for MacOS, resources for Linux and Windows)
extraResources: # copy the file or directory with matching names directly into the app's resources directory (Contents/Resources for MacOS, resources for Linux and Windows)
- ./assets/**
- from: './release/app/database.db'
to: 'database.db'
Expand All @@ -54,3 +54,4 @@ publish:
provider: github
owner: anserwaseem
repo: easy-accounting
releaseType: release
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
"test": "ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/.bin/jest --watchAll=false",
"lint": "eslint .",
"prepare": "husky"
"prepare": "husky",
"version:bump": "ts-node scripts/bump-version.ts",
"version:bump:minor": "ts-node scripts/bump-version.ts minor",
"version:bump:major": "ts-node scripts/bump-version.ts major",
"prerelease": "npm run version:bump && git add package.json release/app/package.json"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
Expand Down
56 changes: 56 additions & 0 deletions scripts/bump-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import fs from 'fs';
import path from 'path';

type BumpType = 'major' | 'minor' | 'patch';

// get bump type from command line args
const bumpType = (process.argv[2] as BumpType) || 'patch';

// paths to package.json files
const rootPackageJsonPath = path.join(__dirname, '../package.json');
const releasePackageJsonPath = path.join(
__dirname,
'../release/app/package.json',
);

// read package.json files
const rootPackageJson = JSON.parse(
fs.readFileSync(rootPackageJsonPath, 'utf8'),
);
const releasePackageJson = JSON.parse(
fs.readFileSync(releasePackageJsonPath, 'utf8'),
);

// parse current version
const [major, minor, patch] = rootPackageJson.version.split('.').map(Number);

// calculate new version
let newVersion: string;
switch (bumpType) {
case 'major':
newVersion = `${major + 1}.0.0`;
break;
case 'minor':
newVersion = `${major}.${minor + 1}.0`;
break;
case 'patch':
default:
newVersion = `${major}.${minor}.${patch + 1}`;
break;
}

// update versions in both package.json files
rootPackageJson.version = newVersion;
releasePackageJson.version = newVersion;

// write updated package.json files
fs.writeFileSync(
rootPackageJsonPath,
`${JSON.stringify(rootPackageJson, null, 2)}\n`,
);
fs.writeFileSync(
releasePackageJsonPath,
`${JSON.stringify(releasePackageJson, null, 2)}\n`,
);

console.log(`Version bumped to ${newVersion}`);
Loading