diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000000..d494587621e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,89 @@ +name: Nango Release +on: [push, pull_request] +concurrency: + group: pulls/${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + npm-publish: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - name: Publish npm packages + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + shell: bash + run: | + bash ./scripts/publish.sh + #TODO: commit changes to repo + nango-jobs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18.x' + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push container for nango-jobs + run: | + npm run i && npm run ts-build + docker buildx build -f packages/jobs/Dockerfile --platform linux/amd64 -t nangohq/jobs:$(git rev-parse --short HEAD) . --no-cache --output type=registry + # nango-runner: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: docker/setup-buildx-action@v3 + # - uses: actions/setup-node@v3 + # with: + # node-version: '18.x' + # - name: Build and push container for nango-runner + # run: | + # npm run ts-build + # docker buildx build -f packages/runner/Dockerfile --platform linux/amd64 -t nangohq/runner:$(git rev-parse --short HEAD) . --no-cache --output type=registry + # nango-server-prod: + # if: github.ref == 'refs/heads/master' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: docker/setup-buildx-action@v3 + # - uses: actions/setup-node@v3 + # with: + # node-version: '18.x' + # - name: Build and push container for nango-server (prod) + # run: | + # npm run build:prod + # docker buildx build -f packages/server/Dockerfile --platform linux/amd64 -t nangohq/nango-cloud:$(git rev-parse --short HEAD) -t nangohq/nango-cloud:production . --no-cache --output type=registry + # nango-server-staging: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: docker/setup-buildx-action@v3 + # - uses: actions/setup-node@v3 + # with: + # node-version: '18.x' + # - name: Build and push container for nango-server (staging) + # run: | + # npm run build:staging + # # TODO: use nango-cloud image repo for staging also + # docker buildx build -f packages/server/Dockerfile --platform linux/amd64 -t nangohq/nango-cloud-staging:$(git rev-parse --short HEAD) . --no-cache --output type=registry + # nango-server-self-hosted: + # if: github.ref == 'refs/heads/master' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: docker/setup-buildx-action@v3 + # - uses: actions/setup-node@v3 + # with: + # node-version: '18.x' + # - name: Build and push containers for nango-server (self-hosted) + # run: | + # npm run build:enterprise && docker buildx build --platform linux/amd64 -f packages/server/Dockerfile -t nangohq/nango-server:enterprise -t nangohq/nango-server:enterprise-$(git rev-parse --short HEAD) . --no-cache --output type=registry + # npm run build:hosted && docker buildx build --platform linux/amd64 -f packages/server/Dockerfile -t nangohq/nango-server:hosted -t nangohq/nango-server:$(git rev-parse --short HEAD) . --no-cache --output type=registry diff --git a/VERSION b/VERSION new file mode 100644 index 00000000000..6746f23ce65 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.36.74 diff --git a/package-lock.json b/package-lock.json index 564dbcb22ae..268976ed2e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2780,6 +2780,7 @@ }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.9" @@ -2880,11 +2881,13 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "darwin" ], + "peer": true, "engines": { "node": ">=12" } @@ -5034,18 +5037,22 @@ }, "node_modules/@tsconfig/node10": { "version": "1.0.9", + "dev": true, "license": "MIT" }, "node_modules/@tsconfig/node12": { "version": "1.0.11", + "dev": true, "license": "MIT" }, "node_modules/@tsconfig/node14": { "version": "1.0.3", + "dev": true, "license": "MIT" }, "node_modules/@tsconfig/node16": { "version": "1.0.3", + "dev": true, "license": "MIT" }, "node_modules/@tsconfig/node18-strictest-esm": { @@ -5991,6 +5998,7 @@ }, "node_modules/acorn-walk": { "version": "8.2.0", + "dev": true, "license": "MIT", "engines": { "node": ">=0.4.0" @@ -6387,6 +6395,7 @@ }, "node_modules/arg": { "version": "4.1.3", + "dev": true, "license": "MIT" }, "node_modules/argparse": { @@ -7421,6 +7430,7 @@ }, "node_modules/create-require": { "version": "1.1.1", + "dev": true, "license": "MIT" }, "node_modules/cross-fetch": { @@ -7588,6 +7598,7 @@ }, "node_modules/diff": { "version": "4.0.2", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" @@ -7817,6 +7828,7 @@ }, "node_modules/esbuild": { "version": "0.17.19", + "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -10020,6 +10032,7 @@ }, "node_modules/make-error": { "version": "1.3.6", + "dev": true, "license": "ISC" }, "node_modules/marked": { @@ -12951,6 +12964,7 @@ }, "node_modules/ts-node": { "version": "10.9.1", + "dev": true, "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", @@ -13444,6 +13458,7 @@ }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", + "dev": true, "license": "MIT" }, "node_modules/validate-npm-package-name": { @@ -14093,6 +14108,7 @@ }, "node_modules/yn": { "version": "3.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -14139,7 +14155,6 @@ "copyfiles": "^2.4.1", "dotenv": "^16.0.3", "ejs": "^3.1.9", - "esbuild": "^0.17.19", "figlet": "^1.6.0", "js-yaml": "^4.1.0", "memfs": "^3.5.1", @@ -14147,8 +14162,6 @@ "ora": "^6.3.1", "promptly": "^3.2.0", "semver": "^7.5.2", - "ts-node": "^10.9.1", - "typescript": "^5.0.4", "vm": "^0.1.0" }, "bin": { @@ -14168,6 +14181,9 @@ "@types/npm-package-arg": "^6.1.1", "@types/promptly": "^3.0.2", "babel-loader": "^9.1.2", + "esbuild": "^0.17.19", + "ts-node": "^10.9.1", + "typescript": "^5.0.4", "webpack": "^5.85.1", "webpack-cli": "^5.1.3", "webpack-node-externals": "^3.0.0" @@ -14215,6 +14231,7 @@ }, "packages/cli/node_modules/typescript": { "version": "5.0.4", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/packages/cli/docker/docker-compose.yaml b/packages/cli/docker/docker-compose.yaml index 4ff86027ae4..3cf7bbdcdd3 100644 --- a/packages/cli/docker/docker-compose.yaml +++ b/packages/cli/docker/docker-compose.yaml @@ -15,7 +15,7 @@ services: - nango nango-server: - image: nangohq/nango-server:0.36.77 + image: nangohq/nango-server:production container_name: nango-server environment: - TEMPORAL_ADDRESS=temporal:7233 diff --git a/packages/cli/package.json b/packages/cli/package.json index a2bd0d7b457..d1927d75373 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -4,21 +4,23 @@ "description": "Nango's CLI tool.", "type": "module", "main": "dist/index.js", - "bin": "./dist/index.js", + "bin": { + "nango": "dist/index.js" + }, "types": "dist/nango-sync.d.ts", "keywords": [], "author": "bastien@nango.dev", "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/cli" }, "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", "scripts": { - "build": "tsc", + "build": "tsc && npm run copyfiles", "copyfiles": "copyfiles -u 1 lib/templates/* dist", - "postbuild": "npm run copyfiles", - "dev": "npm run copyfiles && tsc -w" + "dev": "npm run copyfiles && tsc -w", + "prepublishOnly": "npm install && npm run build" }, "dependencies": { "@babel/traverse": "^7.22.5", @@ -34,7 +36,6 @@ "copyfiles": "^2.4.1", "dotenv": "^16.0.3", "ejs": "^3.1.9", - "esbuild": "^0.17.19", "figlet": "^1.6.0", "js-yaml": "^4.1.0", "memfs": "^3.5.1", @@ -42,8 +43,6 @@ "ora": "^6.3.1", "promptly": "^3.2.0", "semver": "^7.5.2", - "ts-node": "^10.9.1", - "typescript": "^5.0.4", "vm": "^0.1.0" }, "devDependencies": { @@ -60,6 +59,9 @@ "@types/npm-package-arg": "^6.1.1", "@types/promptly": "^3.0.2", "babel-loader": "^9.1.2", + "esbuild": "^0.17.19", + "ts-node": "^10.9.1", + "typescript": "^5.0.4", "webpack": "^5.85.1", "webpack-cli": "^5.1.3", "webpack-node-externals": "^3.0.0" diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index fceecc91c2c..dd2652e614c 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -6,4 +6,4 @@ }, "references": [{ "path": "../shared" }], "include": ["lib/**/*"] -} +} \ No newline at end of file diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 8d84a80e66f..9b2ad500fee 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -9,10 +9,14 @@ "author": "bastien@nango.dev", "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/frontend" }, "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", + "scripts": { + "build": "tsc", + "prepublishOnly": "npm install && npm run build" + }, "dependencies": {}, "files": [ "dist/**/*.js", diff --git a/packages/jobs/package.json b/packages/jobs/package.json index 04eee212e73..b8741372365 100644 --- a/packages/jobs/package.json +++ b/packages/jobs/package.json @@ -11,7 +11,7 @@ "keywords": [], "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/jobs" }, "dependencies": { @@ -49,4 +49,4 @@ "nodemon": "^3.0.1", "typescript": "^5.3.2" } -} \ No newline at end of file +} diff --git a/packages/node-client/package.json b/packages/node-client/package.json index 95cc6e0f938..08fb6ab4d39 100644 --- a/packages/node-client/package.json +++ b/packages/node-client/package.json @@ -6,7 +6,8 @@ "main": "dist/index.js", "module": "./dist/index.js", "scripts": { - "build": "tsup lib/index.ts --format cjs" + "build": "tsup lib/index.ts --format cjs", + "prepublishOnly": "npm install && npm run build && tsc" }, "exports": { ".": { @@ -19,7 +20,7 @@ "keywords": [], "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/node-client" }, "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", @@ -37,4 +38,4 @@ "devDependencies": { "tsup": "^7.2.0" } -} +} \ No newline at end of file diff --git a/packages/node-client/tsconfig.json b/packages/node-client/tsconfig.json index 40518d51fa2..6e986e8dde7 100644 --- a/packages/node-client/tsconfig.json +++ b/packages/node-client/tsconfig.json @@ -5,4 +5,4 @@ "outDir": "dist" }, "include": ["lib/**/*"] -} +} \ No newline at end of file diff --git a/packages/runner/package.json b/packages/runner/package.json index 4e57d557463..0057b59077c 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -13,7 +13,7 @@ "keywords": [], "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/runner" }, "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", @@ -32,4 +32,4 @@ "@types/node": "^18.7.6", "typescript": "^5.3.2" } -} \ No newline at end of file +} diff --git a/packages/server/package.json b/packages/server/package.json index 845d61c225c..881c3e4bcb8 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -12,7 +12,7 @@ "keywords": [], "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/server" }, "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", @@ -74,4 +74,4 @@ "nodemon": "^3.0.1", "typescript": "^4.7.4" } -} \ No newline at end of file +} diff --git a/packages/shared/package.json b/packages/shared/package.json index 7418812851a..5886a0506f6 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -6,12 +6,13 @@ "main": "dist/lib/index.js", "typings": "dist/lib/index.d.ts", "scripts": { - "build": "rimraf dist && tsc" + "build": "rimraf dist && tsc", + "prepublishOnly": "npm install && npm run build" }, "keywords": [], "repository": { "type": "git", - "url": "https://github.com/NangoHQ/nango", + "url": "git+https://github.com/NangoHQ/nango.git", "directory": "packages/shared" }, "license": "SEE LICENSE IN LICENSE FILE IN GIT REPOSITORY", diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 00000000000..452b315963e --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# exit when any command fails +set -e + +# function to bump and publish a package +# $1: package name +# $2: package version +function bump_and_npm_publish { + if npm view "$1@$2" > /dev/null 2>&1; then + echo "Package '$1@$2' already exists" + else + echo "Publishing '$1@$2'" + npm version "$2" -w "$1" + npm publish --access public -w "$1" + fi +} + +GIT_ROOT_DIR=$(git rev-parse --show-toplevel) + +# get version from VERSION file +VERSION=$(cat "$GIT_ROOT_DIR/VERSION") + +# ensure version is of format x.y.z +if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "VERSION '$VERSION' is not of format x.y.z" + exit 1 +fi + +npm install + +# Node client +bump_and_npm_publish "@nangohq/node" "$VERSION" +npm update @nangohq/node -w @nangohq/shared + +# Shared +node scripts/flows.js +bump_and_npm_publish "@nangohq/shared" "$VERSION" +npm update @nangohq/shared -w nango -w @nangohq/nango-server -w @nangohq/nango-jobs @nangohq/nango-runner + +# CLI +# exporting the NangoSync type +cp "$GIT_ROOT_DIR/packages/shared/dist/lib/sdk/sync.d.ts" "./packages/cli/dist/nango-sync.d.ts" && chmod +x "$GIT_ROOT_DIR/packages/cli/dist/index.js" +bump_and_npm_publish "nango" "$VERSION" + +# Frontend +bump_and_npm_publish "@nangohq/frontend" "$VERSION"