@thisismanta/semantic-version 11.1.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,9 +28,9 @@ commit-msg:
28
28
 
29
29
  ---
30
30
 
31
- ### `npx make-next-release`
31
+ ### `npx make-next-release [--dry-run]`
32
32
 
33
- This command is supposed to be run on **GitHub Actions**. It will run `npm version <new-version>`, which `<new-version>` is automatically derived from your commit messages according to the table below and then it creates a new entry on [**GitHub releases**](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases).
33
+ This command is supposed to be run on **GitHub Actions**. It will run `npm version <new-version>`, which `<new-version>` is automatically derived from your commit messages according to the table below and then it creates a new entry on [**GitHub Releases**](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases).
34
34
 
35
35
  | Commit message type | Trigger |
36
36
  | ------------------- | -------------------------- |
@@ -43,34 +43,39 @@ This command is supposed to be run on **GitHub Actions**. It will run `npm versi
43
43
  // package.json
44
44
  {
45
45
  "scripts": {
46
- "version": "npm run build",
46
+ "preversion": "npm run test",
47
+ "version": "npm run build && git add lib",
47
48
  "postversion": "npm publish"
48
49
  }
49
50
  }
50
51
  ```
51
52
 
53
+ By supplying `--dry-run` argument, it uses `git push --dry-run`, `npm version --ignore-scripts` and creates a new _draft_ **GitHub Release** entry instead, which you may want to [manually delete the _draft_ release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#deleting-a-release) afterward.
54
+
52
55
  ```yml
53
56
  # .github/workflows/push.yml
54
57
  on:
55
58
  push:
56
59
  branches: [master]
57
60
 
61
+ permissions:
62
+ contents: write # Grant Git push and GitHub Release write access to GITHUB_TOKEN
63
+
58
64
  jobs:
59
65
  release:
60
66
  runs-on: ubuntu-latest
61
67
  steps:
62
68
  - uses: actions/checkout@v6
63
69
  with:
64
- fetch-depth: 0 # Ensure Git tags are fetched
70
+ fetch-depth: 0 # Ensure entire Git history and Git tags are accessible
65
71
 
66
72
  - uses: actions/setup-node@v6
67
73
  with:
68
- node-version-file: 'package.json'
69
- cache: npm
74
+ node-version: 22
70
75
 
71
- - run: npm ci # Install semantic-version as part of the dependencies
76
+ - run: npm install @thisismanta/semantic-version@11
72
77
 
73
78
  - run: npx make-next-release
74
79
  env:
75
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make it possible to create a new release using GitHub API
80
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76
81
  ```
@@ -18537,6 +18537,8 @@ function getOctokit(token, options, ...additionalPlugins) {
18537
18537
  //#endregion
18538
18538
  //#region src/make-next-release.ts
18539
18539
  (async function() {
18540
+ const dryRun = process.argv.includes("--dry-run");
18541
+ if (dryRun) console.log("⚠️ Running in dry-run mode.");
18540
18542
  if (!await require_src.run(`git config user.name`).catch(() => "")) {
18541
18543
  console.log("Setting Git commit author for further use in `" + require_src.npm + " version` and `git push` command...");
18542
18544
  const name = context.payload.pusher?.name || context.actor;
@@ -18549,9 +18551,11 @@ function getOctokit(token, options, ...additionalPlugins) {
18549
18551
  console.log("Getting the remote repository...");
18550
18552
  const remote = await require_src.run(`git remote`) || "origin";
18551
18553
  console.log(" remote =", remote);
18554
+ const branch = await require_src.run("git branch --show-current");
18555
+ console.log(" branch =", branch);
18552
18556
  if (!process.env.GITHUB_TOKEN) throw new Error("Expected the environment variable \"GITHUB_TOKEN\" to be set.");
18553
18557
  console.log("Checking if the current setup has the permission to push to the remote repository...");
18554
- await require_src.run(`git push --dry-run ${remote}`);
18558
+ await require_src.run(`git push --dry-run ${remote} refs/heads/${branch}`);
18555
18559
  console.log(" OK");
18556
18560
  console.log("Getting the current package version...");
18557
18561
  const currentVersion = await require_src.getCurrentPackageVersion();
@@ -18570,21 +18574,22 @@ function getOctokit(token, options, ...additionalPlugins) {
18570
18574
  return;
18571
18575
  }
18572
18576
  console.log("Running `" + require_src.npm + " version` command and its pre-post scripts...");
18573
- await require_src.run(`${require_src.npm} version ${releaseType} --git-tag-version --no-commit-hooks`);
18574
- console.log(" OK");
18575
- console.log("Pushing the new version to the remote repository...");
18576
- await require_src.run(`git push --follow-tags ${remote}`);
18577
+ await require_src.run(`${require_src.npm} version ${releaseType} --git-tag-version --no-commit-hooks ${dryRun ? "--dry-run --ignore-scripts" : ""}`);
18577
18578
  console.log(" OK");
18578
18579
  console.log("Verifying the new version...");
18579
18580
  const latestVersion = await require_src.getCurrentPackageVersion();
18580
18581
  console.log(" version =", latestVersion ?? JSON.stringify(latestVersion));
18582
+ console.log("Pushing the new version to the remote repository...");
18583
+ await require_src.run(`git push ${dryRun ? "--dry-run" : ""} --atomic ${remote} refs/heads/${branch} refs/tags/v${latestVersion}`);
18584
+ console.log(" OK");
18581
18585
  console.log("Creating a release note on GitHub...");
18582
18586
  const releaseNote = require_src.getReleaseNote(commits);
18583
18587
  const releaseCreationRespond = await getOctokit(process.env.GITHUB_TOKEN).rest.repos.createRelease({
18584
18588
  ...context.repo,
18585
18589
  tag_name: "v" + latestVersion,
18586
18590
  body: releaseNote,
18587
- make_latest: "legacy"
18591
+ make_latest: "legacy",
18592
+ draft: dryRun
18588
18593
  });
18589
18594
  console.log(" " + releaseCreationRespond.data.html_url);
18590
18595
  console.log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisismanta/semantic-version",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "license": "ISC",
5
5
  "author": "Anantachai Saothong <thisismanta@gmail.com>",
6
6
  "repository": {