Skip to content

Commit

Permalink
Get the increment level to the new semver
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Harding <kyle@balena.io>
  • Loading branch information
klutchell committed Feb 7, 2025
1 parent 1cb2f21 commit 83a89e4
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 2 deletions.
48 changes: 47 additions & 1 deletion .github/workflows/flowzone.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 53 additions & 1 deletion flowzone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,8 @@ jobs:
run: |
npm install -g \
balena-versionist@~0.15.0 \
versionist@^7.0.3
versionist@^7.0.3 \
semver@^7.7.1
npm ls -g
Expand All @@ -1213,6 +1214,34 @@ jobs:
"$(npm root -g)"/versionist/scripts/generate-changelog.sh .
fi
# Get the current version with versionist.
# Note that this does NOT include the config generated by the balena-versionist wrapper.
# Is that going to be a problem for any project types?
- name: Get current version
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
if: inputs.disable_versioning != true
id: current_version
with:
result-encoding: json
script: |
const path = require('path');
const { execSync } = require('child_process');
const runPath = process.env.GITHUB_WORKSPACE;
let version;
try {
version = await execSync('versionist get version', {
cwd: runPath,
});
version = version.toString().trim();
} catch (e) {
core.setFailed(e.message);
}
console.log('Current version: ', version);
return version;
# https://github.com/actions/github-script
- name: Run balena-versionist
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
Expand Down Expand Up @@ -1247,6 +1276,29 @@ jobs:
core.setOutput('tag', `v${version}`);
return version;
# https://github.com/actions/github-script
- name: Tag increment level
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
if: inputs.disable_versioning != true
id: increment
env:
PREVIOUS_VERSION: ${{ steps.current_version.outputs.version }}
NEW_VERSION: ${{ steps.versionist.outputs.semver }}
with:
result-encoding: json
script: |
const path = require('path');
const { execSync } = require('child_process');
// Get global node_modules path
const globalNodeModules = execSync('npm root -g').toString().trim();
const semver = require(path.join(globalNodeModules, 'semver'));
const increment = semver.diff(process.env.PREVIOUS_VERSION, process.env.NEW_VERSION);
console.log('Increment: ', increment);
return increment;
# https://github.com/orgs/community/discussions/50055
# https://www.levibotelho.com/development/commit-a-file-with-the-github-api/
# https://octokit.github.io/rest.js/v21/#git-create-blob
Expand Down

0 comments on commit 83a89e4

Please sign in to comment.