From 12830e306fc9d0a05ad3108bac72a54e7839459f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 8 Jan 2018 20:22:56 +0330 Subject: [PATCH] ci: auto publish nuxt-edge --- .circleci/config.yml | 6 +++--- scripts/{release-next => release-edge} | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) rename scripts/{release-next => release-edge} (60%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 82da90d547..3a49a04d78 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,12 +28,12 @@ jobs: name: Tests command: yarn test && yarn coverage - # Release next + # Release edge - run: - name: Publish nuxt-next + name: Publish nuxt-edge command: | if [ "${CIRCLE_BRANCH}" == "dev" ]; then echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc - ./scripts/release-next && npm publish --tag next + ./scripts/release-edge fi diff --git a/scripts/release-next b/scripts/release-edge similarity index 60% rename from scripts/release-next rename to scripts/release-edge index 618caa40bf..703fab1712 100755 --- a/scripts/release-next +++ b/scripts/release-edge @@ -17,16 +17,29 @@ const originalPackage = readFileSync(packagePath, 'utf-8') const p = JSON.parse(originalPackage) // Change package name -// p.name = 'nuxt-next' +p.name = 'nuxt-edge' // Get latest git commit id const gitCommit = String(spawnSync('git', 'rev-parse --short HEAD'.split(' ')).stdout).trim() // Version with latest git commit id -p.version = p.version.split('-')[0] + '-gh-' + gitCommit +p.version = p.version.split('-')[0] + gitCommit // Write package.json writeFileSync(packagePath, JSON.stringify(p, null, 2) + '\r\n') +// Parse git branch to decide npm tag +let tag = String(spawnSync('git', 'rev-parse --abbrev-ref HEAD'.split(' ')).stdout).trim() + +// dev ~> latest +if (tag === 'dev') { + tag = 'latest' +} + // Log -console.log(p.name + '@' + p.version) // eslint-disable-line no-console +// eslint-disable-next-line no-console +console.log(`publishing ${p.name}@${p.version} with tag ${tag}`) + +// Do publish +// eslint-disable-next-line no-console +console.log(String(spawnSync('npm', `publish --tag ${tag}`.split(' ')).stdout).trim())