Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .github/workflows/npm-publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
Expand All @@ -32,13 +32,16 @@ jobs:
# Get the current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")

# Generate a timestamp for uniqueness
TIMESTAMP=$(date +"%Y%m%d%H%M%S")

# For PR: use PR number in version
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BETA_VERSION="$CURRENT_VERSION-beta.pr.${{ github.event.pull_request.number }}"
BETA_VERSION="$CURRENT_VERSION-beta.pr.${{ github.event.pull_request.number }}.$TIMESTAMP"
else
# For develop: use commit hash
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
BETA_VERSION="$CURRENT_VERSION-beta.$SHORT_SHA"
BETA_VERSION="$CURRENT_VERSION-beta.$SHORT_SHA.$TIMESTAMP"
fi

# Set output for use in next step
Expand All @@ -51,3 +54,22 @@ jobs:
run: npm publish --tag beta --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Comment on PR with published version
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const version = process.env.BETA_VERSION;
const packageName = '@space48/sdm';
const installCmd = `npm install ${packageName}@${version}`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 Beta version published: **${version}**\n\nYou can install this version with:\n\`\`\`bash\n${installCmd}\n\`\`\``
});
env:
BETA_VERSION: ${{ steps.beta-version.outputs.version }}
43 changes: 42 additions & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
Expand All @@ -23,7 +23,48 @@ jobs:
- name: Build
run: npm run build

- name: Get package version
id: package-version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Find related PRs and comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const version = process.env.PACKAGE_VERSION;
const packageName = '@space48/sdm';
const installCmd = `npm install ${packageName}@${version}`;

// Get the commit message to find PR number
const { data: commit } = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.sha
});

// Look for PR references in the commit message (like "Merge pull request #123")
const prMatch = commit.commit.message.match(/Merge pull request #(\d+)/i);

if (prMatch && prMatch[1]) {
const prNumber = parseInt(prMatch[1], 10);

// Comment on the PR
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
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\`\`\``
});

console.log(`Commented on PR #${prNumber} about the new release ${version}`);
} else {
console.log('No PR reference found in the commit message. Skipping comment.');
}
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
.npmrc
/scratch
package-lock.json
/lib
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ packages, you must first configure the @space48 scope in npm.
npm login --registry=https://npm.pkg.github.com --scope=@space48
```

### Enable node 14
### Enable node 20

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


Expand Down
2 changes: 0 additions & 2 deletions lib/bin/generate-docs.d.ts

This file was deleted.

30 changes: 0 additions & 30 deletions lib/bin/generate-docs.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/bin/sdm-watch.d.ts

This file was deleted.

129 changes: 0 additions & 129 deletions lib/bin/sdm-watch.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/bin/sdm.d.ts

This file was deleted.

Loading