Skip to content

Commit af78233

Browse files
authored
chore: Make a custom semantic-release action with build step (#702)
1 parent 5734d5e commit af78233

File tree

5 files changed

+87
-7
lines changed

5 files changed

+87
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Semantic Release
2+
description: Deploy using semantic-release
3+
inputs:
4+
DEFAULT_BRANCH:
5+
description: Name of the default release branch
6+
default: main
7+
DRY_RUN:
8+
description: Runs semantic-release with the "--dry-run" flag to simulate a release but not actually do one
9+
default: false
10+
GITHUB_TOKEN:
11+
description: Token to use to update version in 'package.json' and create GitHub release
12+
required: true
13+
NPM:
14+
description: Whether or not to release as an NPM package
15+
default: false
16+
NPM_TOKEN:
17+
description: Token to publish to NPM (not required for CodeArtifact)
18+
outputs:
19+
VERSION:
20+
description: Version of the new release, or empty if release is unchanged
21+
value: ${{ steps.semantic-release.outputs.version }}
22+
runs:
23+
using: composite
24+
steps:
25+
- name: Installing semantic-release
26+
run: |
27+
echo "Installing semantic-release..."
28+
npm install semantic-release@19 @semantic-release/git@10 --no-save
29+
shell: bash
30+
- name: Run semantic-release
31+
id: semantic-release
32+
env:
33+
DEFAULT_BRANCH: ${{ inputs.DEFAULT_BRANCH }}
34+
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
35+
NPM: ${{ inputs.NPM }}
36+
NPM_TOKEN: ${{ inputs.NPM_TOKEN }}
37+
run: |
38+
echo "version=" >> $GITHUB_OUTPUT
39+
if [ ${{ inputs.DRY_RUN }} == true ]; then
40+
echo "Running semantic-release (dry run)..."
41+
npx semantic-release --dry-run -e ./.github/actions/semantic-release/release.config.js
42+
else
43+
OLD_VERSION=$(node -p -e "require('./package.json').version")
44+
echo "Running semantic-release..."
45+
npx semantic-release -e ./.github/actions/semantic-release/release.config.js
46+
NEW_VERSION=$(node -p -e "require('./package.json').version")
47+
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
48+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
49+
fi
50+
fi
51+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const defaultBranch = process.env.DEFAULT_BRANCH || 'main';
2+
const npmPublish = process.env.NPM === 'true';
3+
4+
module.exports = {
5+
"branches": [
6+
defaultBranch
7+
],
8+
"plugins": [
9+
"@semantic-release/commit-analyzer",
10+
"@semantic-release/github",
11+
[
12+
"@semantic-release/npm",
13+
{
14+
"npmPublish": npmPublish
15+
}
16+
],
17+
"./.github/actions/semantic-release/semantic-release.plugin.build.js",
18+
"@semantic-release/release-notes-generator",
19+
[
20+
"@semantic-release/git",
21+
{
22+
"assets": ["dist", "package.json", "package-lock.json"],
23+
"message": "chore(release): ${nextRelease.version} [skip ci]"
24+
}
25+
]
26+
]
27+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { execSync } = require('child_process');
2+
3+
function prepare(pluginConfig, context) {
4+
execSync('npm run build');
5+
}
6+
7+
module.exports = { prepare };

.github/workflows/release.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ jobs:
2525
cache: npm
2626
- name: Install Dependencies
2727
run: npm ci
28-
- name: Build
29-
run: npm run build
3028
- name: Semantic Release
31-
uses: BrightspaceUI/actions/semantic-release@main
29+
uses: ./.github/actions/semantic-release/
3230
with:
3331
GITHUB_TOKEN: ${{ steps.gh-token.outputs.token }}
3432
NPM: true

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"/src",
88
"/dist"
99
],
10-
"repository": {
11-
"type": "git",
12-
"url": "git+https://github.com/eKoopmans/html2pdf.js.git"
13-
},
10+
"repository": "git@github.com:eKoopmans/html2pdf.js.git",
1411
"keywords": [
1512
"javascript",
1613
"pdf-generation",

0 commit comments

Comments
 (0)