Skip to content

Commit

Permalink
Sdk/publish action (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin authored Jun 19, 2024
1 parent 0d37b0f commit a0a9e32
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 78 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish TS SDK

on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true
type: 'string'

jobs:
publish-ts-sdk:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run version ${{ inputs.version }}
- run: npm run build --if-present
- run: npm test
- run: |
if [[ $VERSION == *"beta"* ]]; then
tag=beta
elif [[ $VERSION == *"alpha"* ]]; then
tag=alpha
else
tag=latest
fi
npm publish --access public --tag $tag \
--workspace sdk/definitions \
--workspace sdk/evm \
--workspace solana \
--workspace sdk/route
env:
VERSION: ${{ inputs.version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry
5 changes: 3 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
},
"dependencies": {
"yargs": "^17.7.2"
}
}
},
"version": "0.1.0-beta.0"
}
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ntt",
"version": "0.0.1-beta.5",
"version": "0.1.0-beta.0",
"type": "module",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -14,10 +14,7 @@
"test:local": "jest --config ./jest.config.ts",
"generate:test": "npm run generate:test --workspaces --if-present",
"build:deps": "npm run build:contracts --workspaces --if-present && npm run generate",
"publish": "npm publish --access public --tag $TAG --workspace sdk/definitions --workspace sdk/evm --workspace solana --workspace sdk/route",
"pub:beta": "TAG=beta npm run publish",
"pub:latest": "TAG=latest npm run publish",
"sync": "tsx sdk/syncVersion.ts && npm install && npm run build"
"version": "tsx setSdkVersion.ts"
},
"devDependencies": {
"@wormhole-foundation/sdk": "0.6.5",
Expand Down
1 change: 0 additions & 1 deletion sdk/VERSION

This file was deleted.

8 changes: 4 additions & 4 deletions sdk/definitions/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@wormhole-foundation/sdk-definitions-ntt",
"version": "0.0.1-beta.5",
"version": "0.1.0-beta.0",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
"url": "git+https://github.com/wormhole-foundation/example-native-token-transfers.git"
},
"bugs": {
"url": "https://github.com/wormhole-foundation/connect-sdk/issues"
"url": "https://github.com/wormhole-foundation/example-native-token-transfers"
},
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme",
"homepage": "https://github.com/wormhole-foundation/example-native-token-transfers#readme",
"directories": {
"test": "__tests__"
},
Expand Down
13 changes: 6 additions & 7 deletions sdk/evm/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"name": "@wormhole-foundation/sdk-evm-ntt",
"version": "0.0.1-beta.5",
"version": "0.1.0-beta.0",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
"url": "git+https://github.com/wormhole-foundation/example-native-token-transfers.git"
},
"bugs": {
"url": "https://github.com/wormhole-foundation/connect-sdk/issues"
"url": "https://github.com/wormhole-foundation/example-native-token-transfers"
},
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme",
"directories": {
"test": "tests"
"test": "__tests__"
},
"license": "Apache-2.0",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"module": "./dist/esm/index.js",
"description": "SDK for EVM chains, used in conjunction with @wormhole-foundation/sdk",
"description": "NTT SDK for EVM chains",
"files": [
"dist/esm",
"dist/cjs"
Expand Down Expand Up @@ -46,7 +45,7 @@
},
"dependencies": {
"@wormhole-foundation/sdk-connect": "0.6.5",
"@wormhole-foundation/sdk-definitions-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-definitions-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-evm": "0.6.5",
"@wormhole-foundation/sdk-evm-core": "0.6.5",
"ethers": "^6.5.1"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

21 changes: 5 additions & 16 deletions sdk/examples/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
{
"name": "@wormhole-foundation/sdk-examples-ntt",
"version": "0.0.1-beta.5",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
},
"bugs": {
"url": "https://github.com/wormhole-foundation/connect-sdk/issues"
},
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme",
"directories": {
"test": "__tests__"
},
"version": "0.1.0-beta.0",
"license": "Apache-2.0",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
Expand Down Expand Up @@ -44,9 +33,9 @@
},
"dependencies": {
"@wormhole-foundation/sdk": "0.6.5",
"@wormhole-foundation/sdk-definitions-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-evm-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-solana-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-route-ntt": "0.0.1-beta.5"
"@wormhole-foundation/sdk-definitions-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-evm-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-solana-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-route-ntt": "0.1.0-beta.0"
}
}
19 changes: 9 additions & 10 deletions sdk/route/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "@wormhole-foundation/sdk-route-ntt",
"version": "0.0.1-beta.5",
"version": "0.1.0-beta.0",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
"url": "git+https://github.com/wormhole-foundation/example-native-token-transfers.git"
},
"bugs": {
"url": "https://github.com/wormhole-foundation/connect-sdk/issues"
"url": "https://github.com/wormhole-foundation/example-native-token-transfers"
},
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme",
"homepage": "https://github.com/wormhole-foundation/example-native-token-transfers#readme",
"directories": {
"test": "__tests__"
},
"license": "Apache-2.0",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"module": "./dist/esm/index.js",
"description": "SDK for Solana, used in conjunction with @wormhole-foundation/sdk",
"description": "Implementation of a Route usable by the Wormhole SDK",
"files": [
"dist/esm",
"dist/cjs"
Expand All @@ -25,8 +25,7 @@
"wormhole",
"sdk",
"typescript",
"ntt",
"solana"
"ntt"
],
"engines": {
"node": ">=16"
Expand All @@ -46,9 +45,9 @@
"ts-node": "^10.9.2"
},
"dependencies": {
"@wormhole-foundation/sdk-definitions-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-solana-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-evm-ntt": "0.0.1-beta.5",
"@wormhole-foundation/sdk-definitions-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-solana-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-evm-ntt": "0.1.0-beta.0",
"@wormhole-foundation/sdk-connect": "0.6.5"
},
"peerDependencies": {
Expand Down
16 changes: 6 additions & 10 deletions sdk/syncVersion.ts → setSdkVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ function updateVersionInPackageJson(
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
}

function getVersion(dir: string): string {
const versionFilePath = path.join(dir, "sdk/VERSION");
const v = fs.readFileSync(versionFilePath);
return v.toString().replace("\n", "");
}

function getPackageName(dir: string): string {
const packageJsonPath = path.join(dir, "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
Expand All @@ -44,9 +38,7 @@ type Workspace = {
package: string;
};

function updateVersionsInWorkspaces(dir: string) {
const version = getVersion(dir);

function updateVersionsInWorkspaces(dir: string, version: string) {
const packageJsonPath = path.join(dir, "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));

Expand All @@ -70,4 +62,8 @@ function updateVersionsInWorkspaces(dir: string) {
});
}

updateVersionsInWorkspaces(path.resolve("."));
const args = process.argv.slice(2);
const version = args[0];
if (!version) throw new Error("A version string must be provided");

updateVersionsInWorkspaces(path.resolve("."), version);
11 changes: 6 additions & 5 deletions solana/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"name": "@wormhole-foundation/sdk-solana-ntt",
"version": "0.0.1-beta.5",
"version": "0.1.0-beta.0",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
"url": "git+https://github.com/wormhole-foundation/example-native-token-transfers.git"
},
"bugs": {
"url": "https://github.com/wormhole-foundation/connect-sdk/issues"
"url": "https://github.com/wormhole-foundation/example-native-token-transfers"
},
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme",

"homepage": "https://github.com/wormhole-foundation/example-native-token-transfers#readme",
"directories": {
"test": "tests"
},
"license": "Apache-2.0",
"main": "./dist/cjs/index.js",
"types": "./dist/cjs/index.d.ts",
"module": "./dist/esm/index.js",
"description": "SDK for Solana, used in conjunction with @wormhole-foundation/sdk",
"description": "NTT SDK for Solana",
"files": [
"dist/esm",
"dist/cjs"
Expand Down

0 comments on commit a0a9e32

Please sign in to comment.