-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb1d491
commit 79ed1a7
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Deploy NPM Package | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version to publish (e.g., 1.0.0)" | ||
default: "1.0.0" | ||
required: true | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.11.0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/Iron | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install -r --frozen-lockfile | ||
|
||
- name: Build the package | ||
run: pnpm nx run build sdk | ||
|
||
- name: Prepare package.json | ||
working-directory: packages/sdk | ||
run: node prepare-package.mjs | ||
env: | ||
INPUT_VERSION: ${{ github.event.inputs.version }} | ||
|
||
- name: Publish to NPM | ||
working-directory: packages/sdk | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_NPM_MATTERLABS_AUTOMATION_TOKEN }} | ||
run: npm publish --access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Temp Deploy NPM Package | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.11.0 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/Iron | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install -r --frozen-lockfile | ||
|
||
- name: Build the package | ||
run: pnpm nx run build sdk | ||
|
||
- name: Prepare package.json | ||
working-directory: packages/sdk | ||
run: node prepare-package.mjs | ||
env: | ||
INPUT_VERSION: "0.0.0-beta.1" | ||
|
||
- name: Publish to NPM | ||
working-directory: packages/sdk | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_NPM_MATTERLABS_AUTOMATION_TOKEN }} | ||
run: npm publish --access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Ignore everything by default | ||
* | ||
|
||
# Include specific files and folders | ||
!dist/ | ||
!src/ | ||
!README.md | ||
|
||
# Ignore unnecessary files | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"private": true, | ||
"type": "module", | ||
"name": "zksync-sso", | ||
"description": "ZKsync Smart Sign On SDK", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { promises as fs } from "fs"; | ||
import path from "path"; | ||
|
||
// Define the path to the package.json | ||
const packageJsonPath = path.resolve("./package.json"); | ||
console.log(packageJsonPath); | ||
|
||
// Get the version from environment variables | ||
const version = process.env.INPUT_VERSION; | ||
if (!version) { | ||
console.error("Error: INPUT_VERSION is required."); | ||
process.exit(1); | ||
} | ||
|
||
async function preparePackageJson() { | ||
try { | ||
// Read the existing package.json | ||
const packageJsonData = await fs.readFile(packageJsonPath, "utf8"); | ||
const packageJson = JSON.parse(packageJsonData); | ||
|
||
// Remove unnecessary properties | ||
delete packageJson.private; | ||
delete packageJson.type; | ||
delete packageJson.publishConfig; | ||
|
||
// Set the new version | ||
packageJson.version = version; | ||
|
||
// Write the updated package.json back to the file | ||
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
|
||
console.log(`Updated package.json for version ${version}`); | ||
} catch (error) { | ||
console.error("Error updating package.json:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
preparePackageJson(); |