Skip to content

Commit

Permalink
fix: release examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 27, 2018
1 parent 5a04bec commit 6a1c3df
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 40 deletions.
26 changes: 8 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
- checkout
- restore_cache: &restore_cache
keys:
- v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-master-
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{checksum ".circleci/config.yml"}}-master-
- run: .circleci/yarn
- run: .circleci/setup_git
- run: yarn exec nps test.base
- store_test_results: &store_test_results
path: ~/cli/reports
- save_cache: &save_cache
key: v1-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- save_cache:
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
Expand All @@ -32,7 +32,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.single
- store_test_results: *store_test_results
- save_cache: *save_cache
node-latest-plugin:
<<: *test
steps:
Expand All @@ -42,7 +41,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.plugin
- store_test_results: *store_test_results
- save_cache: *save_cache
node-latest-multi:
<<: *test
steps:
Expand All @@ -52,7 +50,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.multi
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-base:
<<: *test
docker:
Expand All @@ -64,7 +61,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.base
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-single:
<<: *test
docker:
Expand All @@ -76,7 +72,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.single
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-plugin:
<<: *test
docker:
Expand All @@ -88,7 +83,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.plugin
- store_test_results: *store_test_results
- save_cache: *save_cache
node-8-multi:
<<: *test
docker:
Expand All @@ -100,7 +94,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps test.multi
- store_test_results: *store_test_results
- save_cache: *save_cache

lint:
<<: *test
Expand All @@ -113,7 +106,6 @@ jobs:
- run: .circleci/setup_git
- run: yarn exec nps lint
- store_test_results: *store_test_results
- save_cache: *save_cache

release:
<<: *test
Expand All @@ -124,7 +116,6 @@ jobs:
- run: .circleci/yarn
- run: .circleci/setup_git
- run: ./node_modules/.bin/nps release
- save_cache: *save_cache

example-multi-cli-typescript: &example
<<: *test
Expand All @@ -135,7 +126,6 @@ jobs:
- run: .circleci/yarn
- run: .circleci/setup_git
- run: .circleci/release_example
- save_cache: *save_cache

workflows:
version: 2
Expand Down Expand Up @@ -168,6 +158,6 @@ workflows:
context: org-global
requires:
- release
- example-multi-cli-javascript: *example_workflow
- example-single-cli-typescript: *example_workflow
- example-single-cli-javascript: *example_workflow
# - example-multi-cli-javascript: *example_workflow
# - example-single-cli-typescript: *example_workflow
# - example-single-cli-javascript: *example_workflow
30 changes: 9 additions & 21 deletions .circleci/release_example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const fs = require('fs-extra')

sh.set('-ev')

const {version} = fs.readJSONSync('package.json')
sh.exec('yarn link')
const version = process.args[1]
const example = process.env.CIRCLE_JOB
const [, type,, format] = example.split('-')

Expand All @@ -25,41 +26,28 @@ sh.rm('-rf', [
'.eslintrc',
'.gitattributes',
'.gitignore',
'README.md',
'appveyor.yml',
'bin',
'lib',
'package-scripts.js',
'README.md',
'src',
'test',
'tsconfig.json',
'tslint.json',
'yarn.lock'
].join(' '))
'yarn.lock',
])

const pjson = fs.readJSONSync('package.json')
fs.outputJSONSync('package.json', {
name: `@dxcli/${example}`,
repository: `dxcli/${example}`,
author: pjson.author,
version: pjson.version,
description: pjson.description,
})

sh.exec(`yarn create dxcli ${type} --force --defaults ${options}`)
sh.exec('git add .')
sh.exec(`create-dxcli ${type} --force --defaults ${options}`)
sh.exec('git add -A')
sh.exec(`git commit -m "fix: create-dxcli ${version}"`)
sh.exec('git push')
sh.cd('../..')
sh.exec(`git add examples/${example}`)
sh.exec(`git commit -m "chore: ${example} updated [ci-skip]`)

let retries = 4
function push() {
try {
sh.exec('git pull --rebase origin master')
sh.exec('git push')
} catch (err) {
retries--
if (retries > 0) return push()
throw err
}
}
2 changes: 1 addition & 1 deletion examples/example-multi-cli-typescript
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"devDependencies": {
"@dxcli/dev": "^2.0.2",
"@dxcli/dev-test": "^0.9.11",
"@semantic-release/exec": "^1.0.2",
"@types/shelljs": "^0.7.7",
"@types/yeoman-generator": "^2.0.1",
"@types/yosay": "^0.0.29",
Expand Down
23 changes: 23 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable no-template-curly-in-string */

module.exports = {
verifyConditions: [
'@semantic-release/changelog',
'@semantic-release/npm',
'@semantic-release/git',
'@semantic-release/github',
],
publish: [
{
path: '@semantic-release/exec',
cmd: './.circleci/release_example ${nextRelease.version}',
},
'@semantic-release/changelog',
'@semantic-release/npm',
{
path: '@semantic-release/git',
assets: ['package.json', 'examples', 'CHANGELOG.md'],
},
'@semantic-release/github',
],
}
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@
version "2.1.0"
resolved "https://registry.yarnpkg.com/@semantic-release/error/-/error-2.1.0.tgz#44771f676f5b148da309111285a97901aa95a6e0"

"@semantic-release/exec@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@semantic-release/exec/-/exec-1.0.2.tgz#655405003d7e694b66ffcb7658dfa59ce9b141bc"
dependencies:
"@semantic-release/error" "^2.1.0"
debug "^3.1.0"
execa "^0.9.0"
lodash "^4.17.4"
parse-json "^4.0.0"

"@semantic-release/git@^2.0.2":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@semantic-release/git/-/git-2.0.3.tgz#4348a525ec6dfeb9c43ab4ee8d06813583d05644"
Expand Down

0 comments on commit 6a1c3df

Please sign in to comment.