Skip to content

Commit 7bbc7b7

Browse files
authored
Merge pull request #56 from Space48/S48-2368_SDM-Connectors-Issue-with-Node-fetch
S48 2368 sdm connectors issue with node fetch Upgrade node fetch Upgrade nodejs to v20 Add npm publish workflow
2 parents 8e5ac83 + 640b7b7 commit 7bbc7b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+141
-23262
lines changed

.github/workflows/npm-publish-beta.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup Node.js
1818
uses: actions/setup-node@v3
1919
with:
20-
node-version: '18.x'
20+
node-version: '20.x'
2121
registry-url: 'https://registry.npmjs.org'
2222

2323
- name: Install dependencies
@@ -32,13 +32,16 @@ jobs:
3232
# Get the current version from package.json
3333
CURRENT_VERSION=$(node -p "require('./package.json').version")
3434
35+
# Generate a timestamp for uniqueness
36+
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
37+
3538
# For PR: use PR number in version
3639
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
37-
BETA_VERSION="$CURRENT_VERSION-beta.pr.${{ github.event.pull_request.number }}"
40+
BETA_VERSION="$CURRENT_VERSION-beta.pr.${{ github.event.pull_request.number }}.$TIMESTAMP"
3841
else
3942
# For develop: use commit hash
4043
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
41-
BETA_VERSION="$CURRENT_VERSION-beta.$SHORT_SHA"
44+
BETA_VERSION="$CURRENT_VERSION-beta.$SHORT_SHA.$TIMESTAMP"
4245
fi
4346
4447
# Set output for use in next step
@@ -51,3 +54,22 @@ jobs:
5154
run: npm publish --tag beta --access public
5255
env:
5356
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
58+
- name: Comment on PR with published version
59+
if: github.event_name == 'pull_request'
60+
uses: actions/github-script@v6
61+
with:
62+
github-token: ${{ secrets.GITHUB_TOKEN }}
63+
script: |
64+
const version = process.env.BETA_VERSION;
65+
const packageName = '@space48/sdm';
66+
const installCmd = `npm install ${packageName}@${version}`;
67+
68+
github.rest.issues.createComment({
69+
issue_number: context.issue.number,
70+
owner: context.repo.owner,
71+
repo: context.repo.repo,
72+
body: `🚀 Beta version published: **${version}**\n\nYou can install this version with:\n\`\`\`bash\n${installCmd}\n\`\`\``
73+
});
74+
env:
75+
BETA_VERSION: ${{ steps.beta-version.outputs.version }}

.github/workflows/npm-publish.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup Node.js
1515
uses: actions/setup-node@v3
1616
with:
17-
node-version: '18.x'
17+
node-version: '20.x'
1818
registry-url: 'https://registry.npmjs.org'
1919

2020
- name: Install dependencies
@@ -23,7 +23,48 @@ jobs:
2323
- name: Build
2424
run: npm run build
2525

26+
- name: Get package version
27+
id: package-version
28+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
29+
2630
- name: Publish to npm
2731
run: npm publish --access public
2832
env:
2933
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34+
35+
- name: Find related PRs and comment
36+
uses: actions/github-script@v6
37+
with:
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
script: |
40+
const version = process.env.PACKAGE_VERSION;
41+
const packageName = '@space48/sdm';
42+
const installCmd = `npm install ${packageName}@${version}`;
43+
44+
// Get the commit message to find PR number
45+
const { data: commit } = await github.rest.repos.getCommit({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
ref: context.sha
49+
});
50+
51+
// Look for PR references in the commit message (like "Merge pull request #123")
52+
const prMatch = commit.commit.message.match(/Merge pull request #(\d+)/i);
53+
54+
if (prMatch && prMatch[1]) {
55+
const prNumber = parseInt(prMatch[1], 10);
56+
57+
// Comment on the PR
58+
await github.rest.issues.createComment({
59+
issue_number: prNumber,
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
body: `🚀 New version published: **${version}**\n\nThis version has been published to npm and is now available.\n\nYou can install it with:\n\`\`\`bash\n${installCmd}\n\`\`\``
63+
});
64+
65+
console.log(`Commented on PR #${prNumber} about the new release ${version}`);
66+
} else {
67+
console.log('No PR reference found in the commit message. Skipping comment.');
68+
}
69+
env:
70+
PACKAGE_VERSION: ${{ steps.package-version.outputs.version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
.npmrc
55
/scratch
66
package-lock.json
7+
/lib

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ packages, you must first configure the @space48 scope in npm.
2626
npm login --registry=https://npm.pkg.github.com --scope=@space48
2727
```
2828

29-
### Enable node 14
29+
### Enable node 20
3030

31-
sdm uses node 14. Use [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) to enable node 14:
31+
sdm uses node 20. Use [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) to enable node 20:
3232
```bash
33-
nvm use 14
33+
nvm use 20
3434
```
3535

3636

lib/bin/generate-docs.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/bin/generate-docs.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

lib/bin/sdm-watch.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/bin/sdm-watch.js

Lines changed: 0 additions & 129 deletions
This file was deleted.

lib/bin/sdm.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)