Skip to content

Commit

Permalink
check my changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerFrontegg committed Nov 5, 2024
1 parent f821f53 commit 139c9d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const { execSync } = require('child_process');
const { writeFileSync } = require('fs');
const path = require('path');

function getCurrentVersion() {
const pkg = require('../projects/frontegg-app/package.json');
const pkg = require('../../projects/frontegg-app/package.json');
const [major = 0, minor = 0, patch = 0] = pkg.version.split('.').map(Number);
return { major, minor, patch };
}
Expand All @@ -16,13 +15,8 @@ function modifyVersion(newVersion) {
writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2), { encoding: 'utf8' });
}

//check current pr labels
function getPrLabels() {
const prLabels = execSync('gh pr view 1 --json labels')?.toString?.() ?? '{}';
return JSON.parse(prLabels).labels ?? [];
}

function versioning() {
export default (minorNeeded) => {
const version = getCurrentVersion();
let newVersion = { ...version };

Expand All @@ -47,4 +41,4 @@ function versioning() {
}


versioning();
;
1 change: 1 addition & 0 deletions .github/scripts/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {default as generateChangeLog} from './generate-changelog.js'
export {default as incrementVersion} from './increment-version.js'
15 changes: 14 additions & 1 deletion .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,22 @@ jobs:
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Set Minor release
id: version_type_minor
if: contains(join(github.event.pull_request.labels.*.name, ','), 'Minor')
run: |
echo "VERSION_TYPE=minor" >> $GITHUB_EN
- name: Update version in package json
uses: actions/github-script@v6
id: 'generated-changelog'
with:
result-encoding: string
script: |
const { incrementVersion } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/index.js`);
return incrementVersion($VERSION_TYPE === 'minor');
- name: Commit Version UP
run: |
yarn increment-version
yarn update-version
- name: "Set Generated changelog"
uses: actions/github-script@v6
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-entry.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const path = require('path');
const {version} = require(path.join(__dirname, '../projects/frontegg-app/package.json'))

console.log({version});
fs.writeFileSync(path.join(__dirname, '../projects/frontegg-app/src/sdkVersion.ts'), `export default { version: '${version}' };\n`, {encoding: 'utf-8'})

0 comments on commit 139c9d7

Please sign in to comment.