Skip to content

Commit

Permalink
Create npm-publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ucatbas authored Jul 29, 2024
1 parent fa5e10d commit c9f5fe0
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Js Sdk Package

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

update-package-json:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
- run: |
node -e "
const fs = require('fs');
const path = './package.json';
const pkg = require(path);
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
pkg.name = repo;
const versionParts = pkg.version.split('.');
versionParts[2] = (parseInt(versionParts[2]) + 1).toString();
pkg.version = versionParts.join('.');
fs.writeFileSync(path, JSON.stringify(pkg, null, 2));
console.log('Updated name:', pkg.name);
console.log('Updated version:', pkg.version);
"
env:
GITHUB_REPOSITORY: ${{ github.repository }}
- run: |
echo "Name and version from package.json:"
cat package.json | jq '.name, .version'

0 comments on commit c9f5fe0

Please sign in to comment.