Skip to content

Commit ce4f6f6

Browse files
committed
Build: releasing development builds with PRs
1 parent ead4edc commit ce4f6f6

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: CI
22
on:
3-
pull_request:
43
push:
5-
branches:
6-
- main
7-
- react-16
4+
85
jobs:
96
test:
107
name: 'Test with Node version: ${{ matrix.node }}'
@@ -34,7 +31,6 @@ jobs:
3431
- name: Run Jest
3532
run: npx jest
3633
publish:
37-
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/react-16' }}
3834
needs: [test]
3935
name: Publish NPM Package
4036
runs-on: ubuntu-latest

release.config.js

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,65 @@
1+
const { execSync } = require('child_process');
2+
const MAIN_BRANCH = 'main';
3+
4+
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
5+
.toString()
6+
.replace('\n', '');
7+
8+
const branchSha = execSync('git rev-parse --short HEAD')
9+
.toString()
10+
.replace('\n', '');
11+
12+
const isMainBranch = branchName === MAIN_BRANCH;
13+
const githubBranchConfig = isMainBranch
14+
? {}
15+
: {
16+
successComment: `
17+
This PR is part of this prerelease version for testing: \${nextRelease.version}
18+
19+
You can test it by using:
20+
\`\`\`bash
21+
npm install react-html-element@\${nextRelease.version}
22+
\`\`\`
23+
`,
24+
};
25+
26+
const extraPlugins = isMainBranch
27+
? [
28+
[
29+
'@semantic-release/git',
30+
{
31+
message:
32+
'Docs: ${nextRelease.version} [skip ci]\n\n${nextRelease.note}',
33+
assets: [
34+
'CHANGELOG.md',
35+
'package.json',
36+
'package-lock.json',
37+
'npm-shrinkwrap.json',
38+
],
39+
},
40+
],
41+
]
42+
: [];
43+
144
module.exports = {
245
repositoryUrl: 'git@github.com:WTW-IM/react-html-element.git',
346
branches: [
447
{ name: 'main' },
548
{ name: 'react-17', channel: 'react-17', prerelease: 'react-17' },
649
{ name: 'react-16', channel: 'react-16' },
50+
{
51+
name: '*',
52+
channel: 'development',
53+
prerelease: `\${name}-${branchSha}`,
54+
},
755
],
856
plugins: [
957
'@semantic-release/commit-analyzer',
1058
'@semantic-release/release-notes-generator',
1159
'@semantic-release/changelog',
12-
'@semantic-release/github',
13-
[
14-
'@semantic-release/git',
15-
{
16-
message:
17-
'Docs: ${nextRelease.version} [skip ci]\n\n${nextRelease.note}',
18-
assets: [
19-
'CHANGELOG.md',
20-
'package.json',
21-
'package-lock.json',
22-
'npm-shrinkwrap.json',
23-
],
24-
},
25-
],
2660
'@semantic-release/npm',
61+
['@semantic-release/github', { ...githubBranchConfig }],
62+
...extraPlugins,
2763
],
2864
preset: 'eslint',
2965
};

0 commit comments

Comments
 (0)