Skip to content

Commit 4effbcc

Browse files
committed
[ci] Enable automated versioning with semantic-version
1 parent 5c081ce commit 4effbcc

File tree

2 files changed

+179
-16
lines changed

2 files changed

+179
-16
lines changed

.travis.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
language: ruby
22
cache:
33
bundler: true
4-
yarn: true
54
sudo: false
65
bundler_args: --path vendor --local --without development
7-
env:
8-
- DATABASE_URL="mysql2://travis@localhost/myapp_test"
9-
before_script:
10-
- mysql -u root -e "CREATE DATABASE myapp_test;"
11-
- mysql -u root -e "GRANT ALL PRIVILEGES ON myapp_test.* TO 'travis'@'%';";
12-
- mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
13-
script:
14-
- bin/rails db:migrate
15-
- RUN_COVERAGE=travis bin/rails test
16-
- bin/rails coverage:report
176
addons:
187
code_climate:
198
repo_token: a42e116d4d68894b025a60cb722a0b9ba2cf1c6497debb02993d0702284d2511
20-
deploy:
21-
provider: script
22-
script: bash website/travis-deploy.sh
23-
on:
24-
branch: master
9+
jobs:
10+
include:
11+
- stage: Tests
12+
env:
13+
- DATABASE_URL="mysql2://travis@localhost/myapp_test"
14+
before_script:
15+
- mysql -u root -e "CREATE DATABASE myapp_test;"
16+
- mysql -u root -e "GRANT ALL PRIVILEGES ON myapp_test.* TO 'travis'@'%';";
17+
- mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
18+
script:
19+
- bin/rails db:migrate
20+
- RUN_COVERAGE=travis bin/rails test
21+
- bin/rails coverage:report
22+
- stage: Release + website update
23+
language: node_js
24+
node_js: lts/*
25+
install: true
26+
script: skip
27+
deploy:
28+
provider: script
29+
skip_cleanup: true
30+
script:
31+
- npx semantic-release
32+
on:
33+
branch: master
34+
- # stage name not required, will continue to use `Release + website update`
35+
language: node_js
36+
node_js: lts/*
37+
cache:
38+
yarn: true
39+
script: skip
40+
deploy:
41+
provider: script
42+
skip_cleanup: true
43+
script: bash website/travis-deploy.sh
44+
on:
45+
branch: master

release.config.js

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// For 1.0 release only
2+
const parserOpts = {
3+
headerPattern: /^\[(\w*)] (.*)$/,
4+
headerCorrespondence: [`type`, `subject`],
5+
};
6+
7+
const writerOpts = {
8+
transform: (commit, context) => {
9+
let discard = true;
10+
const issues = [];
11+
12+
commit.notes.forEach(note => {
13+
note.title = `BREAKING CHANGES`;
14+
discard = false;
15+
});
16+
17+
if (commit.type === 'breaking') {
18+
commit.type = 'Breaking Changes';
19+
discard = false;
20+
}
21+
22+
// Re-categorize
23+
if (commit.type === 'dokku' || commit.type == 'heroku') {
24+
commit.scope = commit.type;
25+
commit.type = 'deploy';
26+
}
27+
if (commit.type === 'readme') {
28+
commit.type = 'docs';
29+
}
30+
if (commit.type === 'codeclimate' || commit.type === 'travis') {
31+
commit.scope = commit.type;
32+
commit.type = 'ci';
33+
}
34+
if (commit.type === 'config') {
35+
commit.type = 'improvement';
36+
}
37+
if (commit.type === 'blazer') {
38+
commit.type = 'fix';
39+
}
40+
41+
// Set up sections
42+
if (commit.type === `feature` || commit.type === 'feat') {
43+
commit.type = `Features`;
44+
} else if (commit.type === `improvement`) {
45+
commit.type = `Improvements`;
46+
} else if (commit.type === `fix`) {
47+
commit.type = `Bug Fixes`;
48+
} else if (commit.type === `perf`) {
49+
commit.type = `Performance Improvements`;
50+
} else if (commit.type === `revert`) {
51+
commit.type = `Reverts`;
52+
} else if (commit.type === `docs`) {
53+
commit.type = `Documentation`;
54+
} else if (commit.type === `style`) {
55+
commit.type = `Styles`;
56+
} else if (commit.type === `refactor`) {
57+
commit.type = `Code Refactoring`;
58+
} else if (commit.type === `test`) {
59+
commit.type = `Tests`;
60+
} else if (commit.type === `deploy`) {
61+
commit.type = `Deployment`;
62+
} else if (discard) {
63+
return;
64+
} else if (commit.type === `build`) {
65+
commit.type = `Build System`;
66+
} else if (commit.type === `ci`) {
67+
commit.type = `Continuous Integration`;
68+
}
69+
70+
if (commit.scope === `*`) {
71+
commit.scope = ``;
72+
}
73+
74+
if (typeof commit.hash === `string`) {
75+
commit.hash = commit.hash.substring(0, 7);
76+
}
77+
78+
if (typeof commit.subject === `string`) {
79+
let url = context.repository
80+
? `${context.host}/${context.owner}/${context.repository}`
81+
: context.repoUrl;
82+
if (url) {
83+
url = `${url}/issues/`;
84+
// Issue URLs.
85+
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
86+
issues.push(issue);
87+
return `[#${issue}](${url}${issue})`;
88+
});
89+
}
90+
if (context.host) {
91+
// User URLs.
92+
commit.subject = commit.subject.replace(
93+
/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g,
94+
(_, username) => {
95+
if (username.includes('/')) {
96+
return `@${username}`;
97+
}
98+
99+
return `[@${username}](${context.host}/${username})`;
100+
}
101+
);
102+
}
103+
}
104+
105+
// remove references that already appear in the subject
106+
commit.references = commit.references.filter(reference => {
107+
if (issues.indexOf(reference.issue) === -1) {
108+
return true;
109+
}
110+
111+
return false;
112+
});
113+
114+
return commit;
115+
},
116+
groupBy: `type`,
117+
commitGroupsSort: `title`,
118+
commitsSort: [`scope`, `subject`],
119+
noteGroupsSort: `title`,
120+
};
121+
122+
module.exports = {
123+
plugins: [
124+
[
125+
'@semantic-release/commit-analyzer',
126+
{
127+
preset: 'angular',
128+
releaseRules: [{ type: 'breaking', release: 'major' }],
129+
parserOpts,
130+
},
131+
],
132+
[
133+
'@semantic-release/release-notes-generator',
134+
{
135+
preset: 'angular',
136+
parserOpts,
137+
writerOpts,
138+
},
139+
],
140+
'@semantic-release/github',
141+
],
142+
};

0 commit comments

Comments
 (0)