diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 14ea390..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: 2.1 -test_build_filters: &test_build_filters - branches: - only: /.*/ - tags: - ignore: /[0-9]+\.[0-9]+\.[0-9]+/ -jobs: - test: - docker: - - image: circleci/node:12.13.0 - steps: - - checkout - - run: npm install - - run: npm run lint -workflows: - test: - jobs: - - test: - filters: *test_build_filters diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..d469246 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,82 @@ +library 'magic-butler-catalogue' + +def PROJECT_NAME = 'logdna-cli' +def CURRENT_BRANCH = [env.CHANGE_BRANCH, env.BRANCH_NAME]?.find{branch -> branch != null} +def DEFAULT_BRANCH = 'master' +def TRIGGER_PATTERN = ".*@logdnabot.*" +def DRY_RUN = CURRENT_BRANCH != DEFAULT_BRANCH +def CHANGE_ID = env.CHANGE_ID == null ? '' : env.CHANGE_ID + +pipeline { + agent none + + options { + timestamps() + ansiColor 'xterm' + } + + triggers { + issueCommentTrigger(TRIGGER_PATTERN) + } + + environment { + GITHUB_TOKEN = credentials('github-api-token') + NPM_TOKEN = credentials('npm-publish-token') + NPM_CONFIG_CACHE = '.npm' + NPM_CONFIG_USERCONFIG = '.npmrc' + SPAWN_WRAP_SHIM_ROOT = '.npm' + } + + stages { + + stage('Test Release') { + when { + beforeAgent true + not { + branch DEFAULT_BRANCH + } + } + + agent { + docker { + image "us.gcr.io/logdna-k8s/node:14-ci" + customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}" + } + } + + environment { + GIT_BRANCH = "${CURRENT_BRANCH}" + BRANCH_NAME = "${CURRENT_BRANCH}" + CHANGE_ID = "" + } + + steps { + sh 'npm install' + sh 'npm run release:dry' + } + } + + stage ('Release') { + agent { + docker { + image "us.gcr.io/logdna-k8s/node:14-ci" + customWorkspace "${PROJECT_NAME}-${BUILD_NUMBER}" + } + } + + when { + beforeAgent true + branch DEFAULT_BRANCH + not { + changelog '\\[skip ci\\]' + } + } + + steps { + sh "mkdir -p ${NPM_CONFIG_CACHE}" + sh 'npm install' + sh 'npm run release' + } + } + } +} diff --git a/README.md b/README.md index d636202..dad6ca3 100644 --- a/README.md +++ b/README.md @@ -10,36 +10,10 @@ The LogDNA CLI allows you to sign up for a new account and tail your logs right ## Getting Started -### macOS +Install [Node.JS](https://nodejs.org/en/) -Download the [LogDNA CLI installer for Mac](http://repo.logdna.com/mac/logdna-cli.pkg). - -Alternatively install via [brew cask](https://caskroom.github.io/): -``` -brew cask update -brew cask install logdna-cli -``` - -### Windows - -To install on Windows, using [chocolatey](https://chocolatey.org): - -``` -choco install logdna -``` - -### Linux - -For Ubuntu/Debian: - -```bash -sudo wget -qO /tmp/logdna-cli.deb http://repo.logdna.com/linux/logdna-cli.deb && sudo dpkg -i /tmp/logdna-cli.deb -``` - -For RHEL/CentOS: - -```bash -sudo wget -qO /tmp/logdna-cli.rpm http://repo.logdna.com/linux/logdna-cli.rpm && sudo rpm -ivh /tmp/logdna-cli.rpm +```shell +npm install -g logdna-cli@latest ``` ### From Source diff --git a/package.json b/package.json index 1ff0dee..57cb24c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,15 @@ "description": "LogDNA CLI", "main": "index.js", "scripts": { - "lint": "node_modules/.bin/grunt lint" + "lint": "node_modules/.bin/grunt lint", + "release": "semantic-release", + "release:dry": "semantic-release --dry-run --no-ci --branches=${BRANCH_NAME:-master}" + }, + "release": { + "branches": [ + "master" + ], + "extends": "semantic-release-config-logdna" }, "repository": { "type": "git", @@ -35,6 +43,8 @@ "grunt-eslint": "^22.0.0", "grunt-exec": "^3.0.0", "grunt-line-remover": "0.0.2", - "load-grunt-tasks": "^5.0.0" + "load-grunt-tasks": "^5.0.0", + "semantic-release": "^17.4.7", + "semantic-release-config-logdna": "^1.3.0" } }