diff --git a/.circleci/config.yml b/.circleci/config.yml index 51c01eb619..0f5f49bbc0 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,3 +33,12 @@ jobs: - run: name: Tests command: yarn test && yarn coverage + + # Release next + - run: + name: Release Next version + command: | + if [ "${CIRCLE_BRANCH}" == "dev" ]; then + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + npm run release-next + fi diff --git a/build/release-next.js b/build/release-next.js new file mode 100644 index 0000000000..e34338d755 --- /dev/null +++ b/build/release-next.js @@ -0,0 +1,31 @@ +#!/usr/bin/env node +const { readFileSync, writeFileSync } = require('fs-extra') +const { resolve } = require('path') +const { spawnSync } = require('child_process') + +// paths +const packagePath = resolve(__dirname, '..', 'package.json') + +// Read original contents of package.json +const originalPackage = readFileSync(packagePath, 'utf-8') + +// Write to backup file +// writeFileSync(packagePath + '.backup', originalPackage) + +// Parse package.json +const p = JSON.parse(originalPackage) + +// Change package name +p.name = 'nuxt-next' + +// Get latest git commit id +const gitCommit = String(spawnSync('git', 'rev-parse --short HEAD'.split(' ')).stdout).trim() + +// Version with git tag +p.version = p.version.split('-')[0] + '-gh-' + gitCommit + +// Write package.json +writeFileSync(packagePath, JSON.stringify(p, null, 2) + '\r\n') + +// Log +console.log(p.name + '@' + p.version) // eslint-disable-line no-console diff --git a/package.json b/package.json index 3ce4ddd946..6ce7f64402 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ "watch": "npm run build:nuxt -- -w", "make-start": "node ./build/start.js", "precommit": "npm run lint", - "prepare": "npm run build && npm run make-start", - "postinstall": "opencollective postinstall || exit 0" + "postinstall": "opencollective postinstall || exit 0", + "release-next": "npm run build && node ./build/release-next && npm publish --tag next" }, "engines": { "node": ">=6.11",