Skip to content

Commit 786c7be

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/form-data-2.5.5
2 parents 808f504 + e33e6ac commit 786c7be

4 files changed

Lines changed: 145 additions & 46 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,81 @@
1-
name: Publish to NPM
1+
name: Publish NPM and Release (on merged PR)
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
semver:
7-
description: "The semantic version to bump"
8-
required: true
9-
type: choice
10-
options:
11-
- patch
12-
- minor
13-
- major
14-
default: "patch"
15-
nodeVersion:
16-
description: "The Node.js version to use"
17-
required: true
18-
type: choice
19-
options:
20-
- "18.x"
21-
- "20.x"
22-
- "22.x"
23-
default: "18.x"
4+
pull_request:
5+
types:
6+
- closed
247

258
jobs:
269
release:
10+
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master' }}
2711
permissions:
2812
contents: write
13+
packages: write
14+
id-token: write
2915

30-
# Use the semver as the job name
31-
name: "Release ${{ github.event.inputs.semver }}"
16+
name: Publish on master (patch)
3217
runs-on: ubuntu-latest
18+
concurrency:
19+
group: publish-pr-${{ github.event.pull_request.number }}
20+
cancel-in-progress: true
3321
steps:
3422
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
23+
with:
24+
fetch-depth: 0
25+
persist-credentials: true
3526

3627
- uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610
3728
with:
38-
node-version: ${{ github.event.inputs.nodeVersion }}
39-
registry-url: "https://registry.npmjs.org"
29+
node-version: 24
30+
registry-url: 'https://registry.npmjs.org'
4031

41-
- name: Bump and commit version
32+
- name: Detect version bump in merged PR
33+
id: detect
4234
run: |
43-
git config --global user.email "github-actions[bot]@github.com"
44-
git config --global user.name "github-actions[bot]"
45-
npm version ${{ github.event.inputs.semver }} --message "chore(release): bump version to %s"
46-
git push --follow-tags
35+
set -euo pipefail
36+
VERSION=$(node -p "require('./package.json').version")
37+
PREV_JSON=$(git show HEAD^:package.json 2>/dev/null || true)
38+
if [ -z "$PREV_JSON" ]; then
39+
echo "No previous package.json found; treating as release"
40+
echo "release=true" >> $GITHUB_OUTPUT
41+
else
42+
PREV_VERSION=$(printf "%s" "$PREV_JSON" | node -e "let s=''; process.stdin.on('data',d=>s+=d); process.stdin.on('end',()=>console.log(JSON.parse(s).version));")
43+
echo "current: $VERSION, previous: $PREV_VERSION"
44+
if [ "$VERSION" != "$PREV_VERSION" ]; then
45+
echo "release=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "release=false" >> $GITHUB_OUTPUT
48+
fi
49+
fi
50+
echo "VERSION=$VERSION" >> $GITHUB_ENV
4751
48-
- name: Publish
49-
run: npm publish
52+
- name: Create annotated tag from package.json and push
53+
if: ${{ steps.detect.outputs.release == 'true' }}
5054
env:
51-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
set -euo pipefail
58+
git config user.email "github-actions[bot]@github.com"
59+
git config user.name "github-actions[bot]"
60+
61+
TAG="v${VERSION}"
62+
echo "Creating annotated tag $TAG from current HEAD"
63+
git tag -a "$TAG" -m "chore(release): $TAG"
64+
git push origin "$TAG"
5265
53-
- name: Set version as env var
66+
- name: Publish to npm (OIDC)
67+
if: ${{ steps.detect.outputs.release == 'true' }}
5468
run: |
55-
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
69+
npm publish
5670
57-
- uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e
58-
name: Release
59-
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
- name: Create GitHub release
72+
if: ${{ steps.detect.outputs.release == 'true' }}
73+
uses: softprops/action-gh-release@aec2ec56f94eb8180ceec724245f64ef008b89f5
6174
with:
62-
tag_name: ${{ env.VERSION }}
63-
release_name: Release ${{ env.VERSION }}
64-
draft: false
65-
prerelease: false
75+
tag_name: v${{ env.VERSION }}
76+
name: Release ${{ env.VERSION }}
77+
78+
- name: No version bump detected — skipping publish
79+
if: ${{ steps.detect.outputs.release != 'true' }}
80+
run: |
81+
echo "No package.json version bump detected in merged PR; skipping tagging and publish."
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Update Version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
semver:
7+
description: "The semantic version to bump"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
default: "patch"
15+
nodeVersion:
16+
description: "The Node.js version to use"
17+
required: true
18+
type: choice
19+
options:
20+
- "18.x"
21+
- "20.x"
22+
- "22.x"
23+
default: "18.x"
24+
25+
jobs:
26+
release:
27+
permissions:
28+
contents: write
29+
pull-requests: read
30+
31+
name: Update and publish version ${{ github.event.inputs.semver }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
35+
with:
36+
fetch-depth: 0
37+
persist-credentials: true
38+
39+
- uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610
40+
with:
41+
node-version: ${{ github.event.inputs.nodeVersion }}
42+
registry-url: "https://registry.npmjs.org"
43+
44+
- name: Create release branch, bump version and push
45+
env:
46+
SEMVER: ${{ github.event.inputs.semver }}
47+
run: |
48+
set -euo pipefail
49+
git config --global user.email "github-actions[bot]@github.com"
50+
git config --global user.name "github-actions[bot]"
51+
52+
# Create a unique release branch so the bump commit and tag are isolated
53+
BRANCH="release-${SEMVER}-$(date +%s)"
54+
git checkout -b "$BRANCH"
55+
56+
57+
# Bump version but do NOT create a git tag on the branch
58+
npm version "$SEMVER" --no-git-tag-version --allow-same-version --message "chore(release): bump version to %s"
59+
60+
# Commit package.json and package-lock.json (if present) and push branch
61+
git add package.json package-lock.json || true
62+
git commit -m "chore(release): bump version" || true
63+
git push --set-upstream origin "$BRANCH"
64+
65+
# Read the new version for PR title/body and persist values for next step
66+
VERSION=$(node -p "require('./package.json').version")
67+
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
68+
echo "VERSION=$VERSION" >> $GITHUB_ENV
69+
70+
- name: Provide PR creation link
71+
env:
72+
GITHUB_REPOSITORY: ${{ github.repository }}
73+
run: |
74+
set -euo pipefail
75+
PR_LINK="https://github.com/${GITHUB_REPOSITORY}/compare/master...${BRANCH}?expand=1"
76+
echo "Open this URL to create the PR: ${PR_LINK}"
77+
{
78+
echo "## Version bump branch created";
79+
echo "Branch: ${BRANCH}";
80+
echo "Version: ${VERSION}";
81+
echo "";
82+
echo "[Create the pull request now](${PR_LINK})";
83+
} >> "$GITHUB_STEP_SUMMARY"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-vault",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"description": "Javascript client for HashiCorp's Vault",
55
"main": "./src/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)