-
Notifications
You must be signed in to change notification settings - Fork 41
TypeScript SDK for Exosphere #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c7f4472
5afef41
07f961b
12cf7e1
f559144
85621fd
538089d
0cc1335
23ff53f
89a1e39
af1ec83
b74621c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,183 @@ | ||||||||||||
| name: Build & publish TypeScript SDK to npm | ||||||||||||
|
|
||||||||||||
| on: | ||||||||||||
| push: | ||||||||||||
| branches: | ||||||||||||
| - main | ||||||||||||
| paths: | ||||||||||||
| - "typescript-sdk/**" | ||||||||||||
| - ".github/workflows/publish-typescript-sdk.yml" | ||||||||||||
| release: | ||||||||||||
| types: [published] | ||||||||||||
| workflow_dispatch: | ||||||||||||
|
|
||||||||||||
| permissions: | ||||||||||||
| contents: write | ||||||||||||
| id-token: write | ||||||||||||
| jobs: | ||||||||||||
| test: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| defaults: | ||||||||||||
| run: | ||||||||||||
| working-directory: typescript-sdk | ||||||||||||
|
|
||||||||||||
| steps: | ||||||||||||
| - name: Checkout code | ||||||||||||
| uses: actions/checkout@v4 | ||||||||||||
|
|
||||||||||||
| - name: Set up Node.js | ||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||
| with: | ||||||||||||
| node-version: '20' | ||||||||||||
| cache: 'npm' | ||||||||||||
| cache-dependency-path: typescript-sdk/package-lock.json | ||||||||||||
|
|
||||||||||||
| - name: Install dependencies | ||||||||||||
| run: npm ci | ||||||||||||
|
|
||||||||||||
| - name: Run TypeScript compilation | ||||||||||||
| run: npm run build | ||||||||||||
|
|
||||||||||||
| - name: Run tests | ||||||||||||
| run: npm run test:run | ||||||||||||
|
|
||||||||||||
| - name: Run test coverage | ||||||||||||
| run: npm run test:coverage | ||||||||||||
|
|
||||||||||||
| - name: Upload coverage reports to Codecov | ||||||||||||
| uses: codecov/codecov-action@v5 | ||||||||||||
| with: | ||||||||||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||||||||||
| slug: exospherehost/exospherehost | ||||||||||||
| files: typescript-sdk/coverage/lcov.info | ||||||||||||
| flags: typescript-sdk-unittests | ||||||||||||
| name: typescript-sdk-coverage-report | ||||||||||||
| fail_ci_if_error: true | ||||||||||||
|
|
||||||||||||
| - name: Upload test results | ||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||
| if: always() | ||||||||||||
| with: | ||||||||||||
| name: typescript-sdk-test-results | ||||||||||||
| path: typescript-sdk/coverage/ | ||||||||||||
| retention-days: 30 | ||||||||||||
|
|
||||||||||||
| publish: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| needs: test | ||||||||||||
| defaults: | ||||||||||||
| run: | ||||||||||||
| working-directory: typescript-sdk | ||||||||||||
| if: github.repository == 'exospherehost/exospherehost' | ||||||||||||
|
|
||||||||||||
| steps: | ||||||||||||
| - name: Checkout code | ||||||||||||
| uses: actions/checkout@v4 | ||||||||||||
|
|
||||||||||||
| - name: Set up Node.js | ||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||
| with: | ||||||||||||
| node-version: '20' | ||||||||||||
| cache: 'npm' | ||||||||||||
| cache-dependency-path: typescript-sdk/package-lock.json | ||||||||||||
| registry-url: 'https://registry.npmjs.org' | ||||||||||||
|
|
||||||||||||
| - name: Install dependencies | ||||||||||||
| run: npm ci | ||||||||||||
|
|
||||||||||||
| - name: Build package | ||||||||||||
| run: npm run build | ||||||||||||
|
|
||||||||||||
| - name: Check version for beta indicator | ||||||||||||
| run: | | ||||||||||||
| VERSION=$(node -p "require('./package.json').version") | ||||||||||||
| if [[ "$VERSION" == *"b"* ]]; then | ||||||||||||
| echo "Version $VERSION contains beta indicator - publishing to npm with beta tag" | ||||||||||||
| echo "NPM_TAG=beta" >> $GITHUB_ENV | ||||||||||||
| else | ||||||||||||
| echo "Version $VERSION does not contain beta indicator - publishing to npm with latest tag" | ||||||||||||
| echo "NPM_TAG=latest" >> $GITHUB_ENV | ||||||||||||
| fi | ||||||||||||
|
Comment on lines
+91
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix beta tag detection; matching any “b” is unsafe. Use prerelease detection consistent with semver - - name: Check version for beta indicator
+ - name: Determine npm tag from semver prerelease
run: |
- VERSION=$(node -p "require('./package.json').version")
- if [[ "$VERSION" == *"b"* ]]; then
- echo "Version $VERSION contains beta indicator - publishing to npm with beta tag"
- echo "NPM_TAG=beta" >> $GITHUB_ENV
- else
- echo "Version $VERSION does not contain beta indicator - publishing to npm with latest tag"
- echo "NPM_TAG=latest" >> $GITHUB_ENV
- fi
+ VERSION=$(node -p "require('./package.json').version")
+ if [[ "$VERSION" == *"-beta."* ]]; then
+ echo "NPM_TAG=beta" >> "$GITHUB_ENV"
+ elif [[ "$VERSION" == *"-"* ]]; then
+ # Other prereleases (alpha/rc) -> publish under 'next'
+ echo "NPM_TAG=next" >> "$GITHUB_ENV"
+ else
+ echo "NPM_TAG=latest" >> "$GITHUB_ENV"
+ fi🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| - name: Generate SBOM with CycloneDX | ||||||||||||
| run: | | ||||||||||||
| npm install -g @cyclonedx/cyclonedx-npm | ||||||||||||
| cyclonedx-npm --output-file sbom-cyclonedx.json | ||||||||||||
| echo "Generated CycloneDX SBOM in JSON format" | ||||||||||||
|
|
||||||||||||
| - name: Run npm audit | ||||||||||||
| run: | | ||||||||||||
| npm audit --audit-level=moderate --json > vulnerability-report.json || true | ||||||||||||
| echo "Generated vulnerability report (non-blocking)" | ||||||||||||
|
|
||||||||||||
| - name: Publish to npm | ||||||||||||
| run: npm publish --tag ${{ env.NPM_TAG }} --access public | ||||||||||||
| env: | ||||||||||||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||
|
|
||||||||||||
| - name: Upload SBOM artifacts | ||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||
| with: | ||||||||||||
| name: sbom-artifacts-typescript-sdk-${{ github.sha }} | ||||||||||||
| path: | | ||||||||||||
| typescript-sdk/sbom-cyclonedx.json | ||||||||||||
| typescript-sdk/vulnerability-report.json | ||||||||||||
| retention-days: 30 | ||||||||||||
|
|
||||||||||||
| release: | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| needs: [test, publish] | ||||||||||||
| if: github.event_name == 'release' && github.event.action == 'published' | ||||||||||||
| defaults: | ||||||||||||
| run: | ||||||||||||
| working-directory: typescript-sdk | ||||||||||||
|
|
||||||||||||
| steps: | ||||||||||||
| - name: Checkout code | ||||||||||||
| uses: actions/checkout@v4 | ||||||||||||
|
|
||||||||||||
| - name: Set up Node.js | ||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||
| with: | ||||||||||||
| node-version: '20' | ||||||||||||
| cache: 'npm' | ||||||||||||
| cache-dependency-path: typescript-sdk/package-lock.json | ||||||||||||
| registry-url: 'https://registry.npmjs.org' | ||||||||||||
|
|
||||||||||||
| - name: Install dependencies | ||||||||||||
| run: npm ci | ||||||||||||
|
|
||||||||||||
| - name: Build package | ||||||||||||
| run: npm run build | ||||||||||||
|
|
||||||||||||
| - name: Publish to npm with latest tag | ||||||||||||
| run: npm publish --tag latest --access public | ||||||||||||
| env: | ||||||||||||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+153
to
+157
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid republishing on release event. Publishing already happens in - - name: Publish to npm with latest tag
- run: npm publish --tag latest --access public
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ # Publishing happens in the 'publish' job on push. Skip duplicate publish here.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| - name: Create GitHub Release | ||||||||||||
| uses: actions/create-release@v1 | ||||||||||||
| env: | ||||||||||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||
| with: | ||||||||||||
| tag_name: ${{ github.event.release.tag_name }} | ||||||||||||
| release_name: ${{ github.event.release.name }} | ||||||||||||
| body: | | ||||||||||||
| ## TypeScript SDK Release ${{ github.event.release.tag_name }} | ||||||||||||
|
|
||||||||||||
| This release includes the TypeScript SDK for ExosphereHost. | ||||||||||||
|
|
||||||||||||
| ### Installation | ||||||||||||
| ```bash | ||||||||||||
| npm install exospherehost@${{ github.event.release.tag_name }} | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ### Changes | ||||||||||||
| ${{ github.event.release.body }} | ||||||||||||
|
|
||||||||||||
| ### Package Information | ||||||||||||
| - **Package Name**: exospherehost | ||||||||||||
| - **Version**: ${{ github.event.release.tag_name }} | ||||||||||||
| - **Registry**: https://www.npmjs.com/package/exospherehost | ||||||||||||
| draft: false | ||||||||||||
| prerelease: ${{ contains(github.event.release.tag_name, 'beta') || contains(github.event.release.tag_name, 'alpha') || contains(github.event.release.tag_name, 'rc') }} | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| node_modules | ||
| Dist | ||
| dist | ||
nk-ag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| node_modules/ | ||
| dist/ | ||
| # build cache / type info | ||
| *.tsbuildinfo | ||
| # coverage / vitest | ||
| coverage/ | ||
| .vitest/ | ||
| .vite/ | ||
| # logs & OS junk | ||
| npm-debug.log* | ||
| yarn-error.log* | ||
| .DS_Store | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent double publishing; gate publish job to push events only.
Currently runs on
releaseevents too (andreleasejob also publishes), risking duplicate publish failures.📝 Committable suggestion
🤖 Prompt for AI Agents