Skip to content

Commit 7286664

Browse files
committed
configure CI pipeline
1 parent 067c0d7 commit 7286664

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- 58-support-setting-extra-discount-pkr-in-sale-invoice
6+
7+
jobs:
8+
release:
9+
runs-on: ${{ matrix.os }}
10+
11+
strategy:
12+
matrix:
13+
os: [macos-latest, windows-latest]
14+
15+
steps:
16+
- name: Check out Git repository
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Install Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 16
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: |
30+
npm install
31+
32+
- name: Bump version
33+
if: matrix.os == 'macos-latest'
34+
run: |
35+
git config --global user.name 'GitHub Actions'
36+
git config --global user.email 'actions@github.com'
37+
npm run version:bump
38+
npm install --package-lock-only
39+
cd release/app && npm install --package-lock-only && cd ../..
40+
git add package.json package-lock.json release/app/package.json release/app/package-lock.json
41+
git commit -m "chore: bump version [skip ci]"
42+
git tag "v$(node -p "require('./package.json').version")"
43+
git push --follow-tags
44+
45+
- name: Build and release
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
npm run package
50+
npm run release

electron-builder.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ directories:
4343
app: release/app
4444
buildResources: assets
4545
output: release/build
46-
extraResources: # copy the file or directory with matching names directly into the apps resources directory (Contents/Resources for MacOS, resources for Linux and Windows)
46+
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)
4747
- ./assets/**
4848
- from: './release/app/database.db'
4949
to: 'database.db'
@@ -54,3 +54,4 @@ publish:
5454
provider: github
5555
owner: anserwaseem
5656
repo: easy-accounting
57+
releaseType: release

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
4646
"test": "ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/.bin/jest --watchAll=false",
4747
"lint": "eslint .",
48-
"prepare": "husky"
48+
"prepare": "husky",
49+
"version:bump": "ts-node scripts/bump-version.ts",
50+
"version:bump:minor": "ts-node scripts/bump-version.ts minor",
51+
"version:bump:major": "ts-node scripts/bump-version.ts major",
52+
"prerelease": "npm run version:bump && git add package.json release/app/package.json"
4953
},
5054
"lint-staged": {
5155
"*.{js,jsx,ts,tsx}": [

scripts/bump-version.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
type BumpType = 'major' | 'minor' | 'patch';
5+
6+
// get bump type from command line args
7+
const bumpType = (process.argv[2] as BumpType) || 'patch';
8+
9+
// paths to package.json files
10+
const rootPackageJsonPath = path.join(__dirname, '../package.json');
11+
const releasePackageJsonPath = path.join(
12+
__dirname,
13+
'../release/app/package.json',
14+
);
15+
16+
// read package.json files
17+
const rootPackageJson = JSON.parse(
18+
fs.readFileSync(rootPackageJsonPath, 'utf8'),
19+
);
20+
const releasePackageJson = JSON.parse(
21+
fs.readFileSync(releasePackageJsonPath, 'utf8'),
22+
);
23+
24+
// parse current version
25+
const [major, minor, patch] = rootPackageJson.version.split('.').map(Number);
26+
27+
// calculate new version
28+
let newVersion: string;
29+
switch (bumpType) {
30+
case 'major':
31+
newVersion = `${major + 1}.0.0`;
32+
break;
33+
case 'minor':
34+
newVersion = `${major}.${minor + 1}.0`;
35+
break;
36+
case 'patch':
37+
default:
38+
newVersion = `${major}.${minor}.${patch + 1}`;
39+
break;
40+
}
41+
42+
// update versions in both package.json files
43+
rootPackageJson.version = newVersion;
44+
releasePackageJson.version = newVersion;
45+
46+
// write updated package.json files
47+
fs.writeFileSync(
48+
rootPackageJsonPath,
49+
`${JSON.stringify(rootPackageJson, null, 2)}\n`,
50+
);
51+
fs.writeFileSync(
52+
releasePackageJsonPath,
53+
`${JSON.stringify(releasePackageJson, null, 2)}\n`,
54+
);
55+
56+
console.log(`Version bumped to ${newVersion}`);

0 commit comments

Comments
 (0)