Skip to content

Commit

Permalink
Increase major version on definition new Major version - #45
Browse files Browse the repository at this point in the history
  • Loading branch information
haimkastner committed Jul 12, 2024
1 parent cf5defc commit c7618e3
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 8 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- name: Install node
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'

- name: Prepare dependencies
Expand All @@ -74,13 +74,15 @@ jobs:
cd ..
yarn install --frozen-lockfile
- name: Bomb Version
- name: Increase Version
id: update_version
run: |
git pull
version=$(npm --no-git-tag-version --tag-version-prefix= version patch)
echo $version
echo "VERSION=$version" >> $GITHUB_OUTPUT
VERSION=$(node -p "require('./package.json').version")
DEFINITION_VERSION=$(node -p "require('./package.json').definitionVersion")
CURRENT_DEFINITION=$(node ./scripts/definition-version.js)
NEXT_VERSION=$(node ./scripts/next-package-version.js $VERSION $DEFINITION_VERSION $CURRENT_DEFINITION)
jq --arg next_version "$NEXT_VERSION" --arg current_definition "$CURRENT_DEFINITION" '.version = $next_version | .definitionVersion = $current_definition' package.json > tmp.json && mv tmp.json package.json
echo "VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: Get version info
id: version_info
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "unitsnet-js",
"version": "3.0.13",
"definitionVersion": "5.54.0",
"description": "A better way to hold unit variables and easily convert to the destination unit",
"scripts": {
"prepublishOnly": "npm run generate && npm run test",
Expand Down Expand Up @@ -28,12 +29,14 @@
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.62",
"@types/numeral": "^2.0.5",
"axios": "^1.7.2",
"chai": "^4.2.0",
"mocha": "^8.1.3",
"numeral": "^2.0.6",
"nyc": "^15.1.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
"typescript": "^3.9.7",
"xml2js": "^0.6.2"
},
"dependencies": {},
"keywords": [
Expand Down
28 changes: 28 additions & 0 deletions scripts/definition-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const axios = require('axios');
const xml2js = require('xml2js');

const url = 'https://raw.githubusercontent.com/angularsen/UnitsNet/master/UnitsNet/UnitsNet.csproj';

axios.get(url)
.then(response => {
const xml = response.data;
xml2js.parseString(xml, (err, result) => {
if (err) {
exit(1);
console.error('Error parsing XML:', err);
process.exit(1);
}

try {
const version = result.Project.PropertyGroup[0].Version[0];
console.log(version);
} catch (e) {
console.error('Error extracting version:', e);
process.exit(1);
}
});
})
.catch(error => {
console.error('Error fetching the URL:', error);
process.exit(1);
});
31 changes: 31 additions & 0 deletions scripts/next-package-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Function to parse version string to major, minor, patch
const parseVersion = (version) => {
const [major, minor, patch] = version.split('.').map(Number);
return { major, minor, patch };
};

// Function to increment the version
const incrementVersion = (currentVersion, definitionVersion, currentDefinitionVersion) => {
const current = parseVersion(currentVersion);
const definition = parseVersion(definitionVersion);
const currentDefinition = parseVersion(currentDefinitionVersion);

if (currentDefinition.major > definition.major) {
// Increment major version
return `${current.major + 1}.0.0`;
} else {
// Increment patch version
return `${current.major}.${current.minor}.${current.patch + 1}`;
}
};

// Get the current version from command line arguments
const [currentVersion, definitionVersion, currentDefinitionVersion] = process.argv.slice(2);

if (!currentVersion || !definitionVersion || !currentDefinitionVersion) {
console.error('Please provide the current version & definition version & current definition version as an argument.');
process.exit(1);
}

const newVersion = incrementVersion(currentVersion, definitionVersion, currentDefinitionVersion);
console.log(newVersion);
75 changes: 75 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ assertion-error@^1.1.0:
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

axios@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621"
integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
Expand Down Expand Up @@ -509,6 +523,13 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"

commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
Expand Down Expand Up @@ -576,6 +597,11 @@ default-require-extensions@^3.0.0:
dependencies:
strip-bom "^4.0.0"

delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

diff@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
Expand Down Expand Up @@ -663,6 +689,11 @@ flat@^5.0.2:
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==

follow-redirects@^1.15.6:
version "1.15.6"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b"
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==

foreground-child@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-2.0.0.tgz#71b32800c9f15aa8f2f83f4a6bd9bff35d861a53"
Expand All @@ -671,6 +702,15 @@ foreground-child@^2.0.0:
cross-spawn "^7.0.0"
signal-exit "^3.0.2"

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

fromentries@^1.2.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/fromentries/-/fromentries-1.3.2.tgz#e4bca6808816bf8f93b52750f1127f5a6fd86e3a"
Expand Down Expand Up @@ -1011,6 +1051,18 @@ make-error@^1.1.1:
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==

mime-db@1.52.0:
version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==

mime-types@^2.1.12:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
dependencies:
mime-db "1.52.0"

minimatch@3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
Expand Down Expand Up @@ -1227,6 +1279,11 @@ process-on-spawn@^1.0.0:
dependencies:
fromentries "^1.2.0"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
Expand Down Expand Up @@ -1275,6 +1332,11 @@ safe-buffer@^5.1.0:
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==

sax@>=0.6.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f"
integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==

semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
Expand Down Expand Up @@ -1530,6 +1592,19 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"

xml2js@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499"
integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==
dependencies:
sax ">=0.6.0"
xmlbuilder "~11.0.0"

xmlbuilder@~11.0.0:
version "11.0.1"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"
integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==

y18n@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
Expand Down

0 comments on commit c7618e3

Please sign in to comment.