Skip to content

Commit eb5d6ce

Browse files
authored
Merge pull request #52 from postmanlabs/feature/automated-release
Automated releases and publish process
2 parents 8743631 + 77ca122 commit eb5d6ce

File tree

5 files changed

+229
-1
lines changed

5 files changed

+229
-1
lines changed

.travis.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,55 @@ jobs:
1818
- npm run test-unit
1919
- bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F unit
2020

21+
# create a new release if $CREATE_RELEASE is set
22+
- stage: Create Release
23+
if: env(CREATE_RELEASE) = true AND type = api AND tag IS blank
24+
os: osx
25+
node_js: 12
26+
git:
27+
depth: false # disable --depth
28+
script:
29+
# fail-fast using set -e
30+
- set -e
31+
# decrypt and ssh-add the deploy-key
32+
- openssl aes-256-cbc -K $encrypted_05f822b6caa8_key -iv $encrypted_05f822b6caa8_iv
33+
-in .github/travis-deploy-key.enc -out /tmp/travis-deploy-key -d
34+
- chmod 600 /tmp/travis-deploy-key
35+
- eval "$(ssh-agent -s)"
36+
- ssh-add /tmp/travis-deploy-key
37+
- rm /tmp/travis-deploy-key
38+
# convert remote URL from HTTPS to SSH
39+
- git remote set-url origin $(git config --get remote.origin.url | sed -E 's#(http.*://)([^/]+)/(.+)$#git@\2:\3#g')
40+
- ssh-keyscan github.com >> ~/.ssh/known_hosts
41+
# create release
42+
- npm run release $PUSH_TO_ORIGIN $PRERELEASE_SUFFIX
43+
- set +e
44+
45+
# publish npm package on tagged builds
46+
- stage: Publish Package
47+
if: tag IS present
48+
os: osx
49+
node_js: 12
50+
git:
51+
depth: false # disable --depth
52+
script:
53+
# fail-fast using set -e
54+
- set -e
55+
# get prerelease suffix from version tag
56+
- TAG=$(echo $TRAVIS_TAG | sed 's/^.*-\([a-z]*\).*$/\1/')
57+
# set to `latest` in case of no suffix
58+
- TAG=$([ "${TAG}" = "$TRAVIS_TAG" ] && echo "latest" || echo $TAG)
59+
# make sure `latest` tag is create from master branch
60+
- '[ "$TAG" = "latest" ] && [ $(git rev-parse HEAD) != $(git rev-parse origin/master) ] && return 1 || return 0'
61+
- set +e
62+
deploy:
63+
edge: true # opt in to dpl v2
64+
provider: npm
65+
tag: $TAG
66+
on:
67+
tags: true
68+
all_branches: true
69+
2170
# update gh-pages docs on master
2271
- stage: Publish Docs
2372
if: branch = master

CHANGELOG.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ master:
55
- GH-49 Dropped support for Node < v10
66
chores:
77
- GH-50 Convert EncodeSet to ES6 class
8+
- GH-52 Automated releases and publish process
89
- GH-51 Automated gh-pages docs deployment
910
- >-
1011
GH-49 Updated .npmignore to prevent the addition of tests and config

npm/create-release.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
// ---------------------------------------------------------------------------------------------------------------------
3+
// This script is intended to automate the versioning and changelog generation process for a release.
4+
// ---------------------------------------------------------------------------------------------------------------------
5+
6+
7+
const shipit = require('@postman/shipit'),
8+
9+
// npm run release [true] [beta]
10+
[pushToOrigin, preReleaseSuffix] = process.argv.splice(2);
11+
12+
// only support `beta` suffix
13+
if (preReleaseSuffix && preReleaseSuffix !== 'beta') {
14+
throw new Error(`Can't prerelease with \`${preReleaseSuffix}\` suffix.`);
15+
}
16+
17+
// 🚢 Just Ship It!
18+
shipit({
19+
// don't push to origin unless explicitly set
20+
pushToOrigin: pushToOrigin === 'true',
21+
// prerelease suffix, if any
22+
preReleaseSuffix: preReleaseSuffix
23+
}).then((version) => {
24+
console.info('🚀', version);
25+
}).catch((err) => {
26+
console.error('🔥', err);
27+
process.exit(1);
28+
});

package-lock.json

Lines changed: 148 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
],
2323
"scripts": {
2424
"build-docs": "node npm/build-docs.js",
25+
"release": "node npm/create-release.js",
2526
"test": "npm run test-lint && npm run test-unit",
2627
"test-benchmark": "node npm/test-benchmark.js",
2728
"test-lint": "node npm/test-lint.js",
@@ -33,12 +34,13 @@
3334
},
3435
"devDependencies": {
3536
"@postman/csv-parse": "^4.0.2",
37+
"@postman/shipit": "0.1.0",
3638
"async": "^3.1.1",
3739
"bipbip": "^0.4.1",
3840
"chai": "^4.2.0",
3941
"chalk": "4.1.0",
40-
"editorconfig": "^0.15.3",
4142
"colors": "^1.4.0",
43+
"editorconfig": "^0.15.3",
4244
"eslint": "^7.10.0",
4345
"eslint-plugin-jsdoc": "^30.6.2",
4446
"eslint-plugin-lodash": "^7.1.0",

0 commit comments

Comments
 (0)