Skip to content

Commit b07cc19

Browse files
committed
chore(release-flow): create automatical a changelog before release and finish TravisCI
[ci skip]
1 parent 9b6740f commit b07cc19

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

.travis.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ matrix:
3535
- OPENSSL_DIR=""
3636
before_install:
3737
- sudo apt-get install -y haveged
38+
- if [ "$TRAVIS_BRANCH" == "master" ]; then
39+
git clone "https://github.com/$TRAVIS_REPO_SLUG.git" "$TRAVIS_REPO_SLUG";
40+
cd "$TRAVIS_REPO_SLUG";
41+
git checkout -qf "$TRAVIS_COMMIT";
42+
fi
3843
before_script:
3944
- npm prune
40-
- sudo haveged -w 4096
45+
- sudo haveged -w 2048
4146
script:
42-
- if [[ "$OPENSSL_DIR" != "" ]]; then "./test_build_openssl.sh" ; fi
47+
- if [[ "$OPENSSL_DIR" != "" ]]; then "./bin/test_build_openssl.sh" ; fi
4348
- npm run test
4449
after_success:
45-
- npm run semantic-release
50+
- if [ "$TRAVIS_NODE_VERSION" == "8" ]; then npm run aftersuccess ; fi
51+
- if [ "$TRAVIS_BRANCH" == "master" ]; then npm run semantic-release ; fi
4652
branches:
4753
except:
4854
- /^v\d+\.\d+\.\d+$/

bin/aftersuccess.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const deployOnce = require('../node_modules/travis-deploy-once')
2+
3+
const makeTest = async function () {
4+
let result
5+
6+
try {
7+
// Options can also be set as environment variables with the same name
8+
result = await deployOnce(
9+
{
10+
// Object passed to https://github.com/pwmckenna/node-travis-ci
11+
travisOpts: {pro: false},
12+
// GitHub oAuth token
13+
GH_TOKEN: process.env.GH_TOKEN,
14+
// Want to control which job is the build leader?
15+
// Set your preferred job id
16+
BUILD_LEADER_ID: 1
17+
}
18+
)
19+
} catch (err) {
20+
// something went wrong, and err will tell you what
21+
console.log(err)
22+
}
23+
24+
if (result === true) {
25+
process.exitCode = 0
26+
console.log(0)
27+
}
28+
if (result === false) {
29+
process.exitCode = 1
30+
console.log(1)
31+
}
32+
if (result === null) {
33+
process.exitCode = 1
34+
console.log(1)
35+
}
36+
return 0
37+
}
38+
39+
makeTest()

bin/aftersuccess.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
4+
OUTPUT=$(node "$(pwd)/bin/aftersuccess.js")
5+
STATUS=$?
6+
7+
echo "${STATUS} ${OUTPUT}"
8+
9+
if [[ "${STATUS}" == "0" ]]
10+
then
11+
git config --global user.name "Dexus via TravisCI"
12+
git config --global user.email "[email protected]"
13+
git config credential.helper "store --file=.git/credentials"
14+
echo "https://$GH_TOKEN:@github.com" > .git/credentials
15+
git checkout "$TRAVIS_BRANCH"
16+
npm run changelog
17+
git add HISTORY.md
18+
git commit -m "Update HISTORY.md via TravisCI" -m "[ci skip]"
19+
git push
20+
fi
File renamed without changes.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"main": "lib/pem",
1919
"scripts": {
20+
"aftersuccess": "bin/aftersuccess.sh",
2021
"documentation": "npm run docco --silent && npm run jsdoc --silent",
2122
"docco": "docco -l parallel -o docs/docco lib/helper.js lib/openssl.js lib/pem.js",
2223
"jsdoc": "jsdoc -c jsdoc.json",
@@ -60,7 +61,8 @@
6061
"jsdoc": "^3.5.5",
6162
"mocha": "^4.0.1",
6263
"nyc": "^11.2.1",
63-
"semantic-release": "^8.1.1"
64+
"semantic-release": "^8.1.1",
65+
"travis-deploy-once": "^3.0.0"
6466
},
6567
"engines": {
6668
"node": ">=4.0.0"

0 commit comments

Comments
 (0)