-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Make a custom semantic-release action with build step (#702)
- Loading branch information
Showing
5 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Semantic Release | ||
description: Deploy using semantic-release | ||
inputs: | ||
DEFAULT_BRANCH: | ||
description: Name of the default release branch | ||
default: main | ||
DRY_RUN: | ||
description: Runs semantic-release with the "--dry-run" flag to simulate a release but not actually do one | ||
default: false | ||
GITHUB_TOKEN: | ||
description: Token to use to update version in 'package.json' and create GitHub release | ||
required: true | ||
NPM: | ||
description: Whether or not to release as an NPM package | ||
default: false | ||
NPM_TOKEN: | ||
description: Token to publish to NPM (not required for CodeArtifact) | ||
outputs: | ||
VERSION: | ||
description: Version of the new release, or empty if release is unchanged | ||
value: ${{ steps.semantic-release.outputs.version }} | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Installing semantic-release | ||
run: | | ||
echo "Installing semantic-release..." | ||
npm install semantic-release@19 @semantic-release/git@10 --no-save | ||
shell: bash | ||
- name: Run semantic-release | ||
id: semantic-release | ||
env: | ||
DEFAULT_BRANCH: ${{ inputs.DEFAULT_BRANCH }} | ||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||
NPM: ${{ inputs.NPM }} | ||
NPM_TOKEN: ${{ inputs.NPM_TOKEN }} | ||
run: | | ||
echo "version=" >> $GITHUB_OUTPUT | ||
if [ ${{ inputs.DRY_RUN }} == true ]; then | ||
echo "Running semantic-release (dry run)..." | ||
npx semantic-release --dry-run -e ./.github/actions/semantic-release/release.config.js | ||
else | ||
OLD_VERSION=$(node -p -e "require('./package.json').version") | ||
echo "Running semantic-release..." | ||
npx semantic-release -e ./.github/actions/semantic-release/release.config.js | ||
NEW_VERSION=$(node -p -e "require('./package.json').version") | ||
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then | ||
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
fi | ||
fi | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const defaultBranch = process.env.DEFAULT_BRANCH || 'main'; | ||
const npmPublish = process.env.NPM === 'true'; | ||
|
||
module.exports = { | ||
"branches": [ | ||
defaultBranch | ||
], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/github", | ||
[ | ||
"@semantic-release/npm", | ||
{ | ||
"npmPublish": npmPublish | ||
} | ||
], | ||
"./.github/actions/semantic-release/semantic-release.plugin.build.js", | ||
"@semantic-release/release-notes-generator", | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": ["dist", "package.json", "package-lock.json"], | ||
"message": "chore(release): ${nextRelease.version} [skip ci]" | ||
} | ||
] | ||
] | ||
}; |
7 changes: 7 additions & 0 deletions
7
.github/actions/semantic-release/semantic-release.plugin.build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { execSync } = require('child_process'); | ||
|
||
function prepare(pluginConfig, context) { | ||
execSync('npm run build'); | ||
} | ||
|
||
module.exports = { prepare }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,7 @@ | |
"/src", | ||
"/dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/eKoopmans/html2pdf.js.git" | ||
}, | ||
"repository": "[email protected]:eKoopmans/html2pdf.js.git", | ||
"keywords": [ | ||
"javascript", | ||
"pdf-generation", | ||
|