Skip to content

Commit 71d60f2

Browse files
committed
chore: align env var names and clean up script a bit
1 parent a389cf6 commit 71d60f2

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

.github/workflows/create-or-update-release-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ jobs:
5353
env:
5454
GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }}
5555
RELEASE_SCOPE: ${{ github.event.inputs.release_scope }}
56-
RELEASE_BUMP: ${{ github.event.inputs.release_type }}
56+
RELEASE_TYPE: ${{ github.event.inputs.release_type }}
5757
RELEASE_PR_REMOTE: origin

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"prepare_release:experimental": "npm run _check:no_changes && npm run _backup:package-json && npm run _workspace:remove_api && npm run _workspace:remove_semconv && npm run _workspace:remove_stable && npm run _workspace:bump_version && npm run _restore:package-json && npm run _changelog:prepare_experimental",
3434
"prepare_release:sdk": "npm run _check:no_changes && npm run _backup:package-json && npm run _workspace:remove_api && npm run _workspace:remove_semconv && npm run _workspace:bump_version && npm run _restore:package-json && npm run _changelog:prepare_experimental && npm run _changelog:prepare_stable",
3535
"prepare_release:semconv": "npm run _check:no_changes && npm run _backup:package-json && npm run _workspace:remove_everything_except_semconv && npm run _workspace:bump_version && npm run _restore:package-json && npm run _changelog:prepare_semconv",
36-
"prepare_release:all": "npm run _check:no_changes && npm run _backup:package-json && npm run _workspace:remove_api && npm run _workspace:remove_semconv && npm run _workspace:bump_version && cd api/ && npm version $RELEASE_BUMP && cd .. && nx run-many -t align-api-deps && npm run _restore:package-json && npm run _changelog:prepare_all",
36+
"prepare_release:all": "npm run _check:no_changes && npm run _backup:package-json && npm run _workspace:remove_api && npm run _workspace:remove_semconv && npm run _workspace:bump_version && cd api/ && npm version $RELEASE_TYPE && cd .. && nx run-many -t align-api-deps && npm run _restore:package-json && npm run _changelog:prepare_all",
3737
"comment_internal": "echo scripts below this line are for internal use",
3838
"_check:no_changes": "if [ ! -z \"$(git status -uall --porcelain)\" ]; then echo Please ensure all changes are committed; exit 1; fi",
3939
"_backup:package-json": "cp package.json package.json.backup",
@@ -59,9 +59,9 @@
5959
"_github:update_release_pr_body:experimental": "node scripts/extract-latest-release-notes.js experimental/CHANGELOG.md && npm run _github:update_release_pr_body_from_file",
6060
"_github:update_release_pr_body:semconv": "node scripts/extract-latest-release-notes.js semantic-conventions/CHANGELOG.md && npm run _github:update_release_pr_body_from_file",
6161
"_verify_release_kind": "echo $RELEASE_SCOPE | grep -oE '^(all|sdk|experimental|semconv)$'",
62-
"_verify_release_bump": "echo $RELEASE_BUMP | grep -oE '^(minor|patch)$'",
62+
"_verify_release_type": "echo $RELEASE_TYPE | grep -oE '^(minor|patch)$'",
6363
"_verify_release_remote": "git remote get-url $RELEASE_PR_REMOTE",
64-
"_github:update_release_branch": "npm run _verify_release_kind && npm run _verify_release_bump && npm run _verify_release_remote && (git checkout main && git pull $RELEASE_PR_REMOTE main && git branch -D otelbot/prepare-next-version; git checkout -b otelbot/prepare-next-version && npm run prepare_release:$RELEASE_SCOPE && git commit -am \"chore: prepare release\" && git push --set-upstream $RELEASE_PR_REMOTE --force otelbot/prepare-next-version)",
64+
"_github:update_release_branch": "npm run _verify_release_kind && npm run _verify_release_type && npm run _verify_release_remote && (git checkout main && git pull $RELEASE_PR_REMOTE main && git branch -D otelbot/prepare-next-version; git checkout -b otelbot/prepare-next-version && npm run prepare_release:$RELEASE_SCOPE && git commit -am \"chore: prepare release\" && git push --set-upstream $RELEASE_PR_REMOTE --force otelbot/prepare-next-version)",
6565
"github:create_or_update_release_pr": "npm run _github:update_release_branch && (gh pr create --repo open-telemetry/opentelemetry-js --title 'chore: prepare next release' --body ''; npm run _github:update_release_pr_body:$RELEASE_SCOPE)"
6666
},
6767
"repository": "open-telemetry/opentelemetry-js",

scripts/bump-versions.mjs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
/**
2+
* This bumps all package versions based on the environment variable RELEASE_TYPE (allowed values 'minor' and 'patch'),
3+
* then aligns all packages in the workspace to depend on that version IFF the dependency version is pinned. Packages
4+
* like `@opentelemetry/semantic-conventions` which are unpinned on purpose will not be bumped.
5+
*
6+
* All packages versions are bumped in unison to satisfy this specification requirement:
7+
* https://github.com/open-telemetry/opentelemetry-specification/blob/v1.49.0/specification/versioning-and-stability.md?plain=1#L353-L355
8+
*
9+
* Usage (from package directory):
10+
* - RELEASE_TYPE=minor node <repo-root>/scripts/bump-versions.js # bumps minor version in all packages
11+
* - RELEASE_TYPE=patch node <repo-root>/scripts/bump-versions.js # bumps patch version in all packages
12+
*/
13+
114
import * as fs from 'fs';
215
import * as path from 'path';
316
import * as glob from 'glob';
417

5-
const RELEASE_BUMP = process.env.RELEASE_BUMP;
18+
const RELEASE_TYPE = process.env.RELEASE_TYPE;
619

7-
if (!['minor', 'patch'].includes(RELEASE_BUMP)) {
8-
console.error('RELEASE_BUMP must be either "minor" or "patch"');
20+
if (!['minor', 'patch'].includes(RELEASE_TYPE)) {
21+
console.error('RELEASE_TYPE must be either "minor" or "patch"');
922
process.exit(1);
1023
}
1124

@@ -58,11 +71,11 @@ packagePaths.forEach(pkgPath => {
5871
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
5972

6073
const oldVersion = pkgJson.version;
61-
const newVersion = bumpVersion(oldVersion, RELEASE_BUMP);
74+
const newVersion = bumpVersion(oldVersion, RELEASE_TYPE);
6275
pkgJson.version = newVersion;
6376
updatedVersions[pkgJson.name] = newVersion;
6477

65-
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
78+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
6679
console.info(`Bumped ${pkgJson.name} from ${oldVersion} to ${newVersion}`);
6780
});
6881

@@ -73,6 +86,6 @@ packagePaths.forEach(pkgPath => {
7386

7487
updatePinnedDependencies(pkgJson, updatedVersions);
7588

76-
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
89+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
7790
console.info(`Updated dependencies for ${pkgJson.name}`);
7891
});

0 commit comments

Comments
 (0)