generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
12 additions
and
143 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
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 |
---|---|---|
|
@@ -18,89 +18,10 @@ on: | |
permissions: | ||
contents: write | ||
|
||
env: | ||
INPUTS_DRY_RUN: ${{ github.event.inputs.dry-run }} | ||
DRY_RUN_OPTION: ${{ github.event.inputs.dry-run == 'true' && '--dry-run' || '' }} | ||
|
||
|
||
jobs: | ||
check-versions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
do-release: ${{ steps.check-versions.outputs.do-release }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Check Versions | ||
id: check-versions | ||
run: | | ||
if [ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]; then | ||
echo "Run as workflow_dispatch: run release" | ||
echo "do-release=true" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
package_name=$(npm pkg get name | tr -d '"') | ||
local_version=$(npm pkg get version | tr -d '"') | ||
npm_version=$(npm show $package_name version) | ||
echo "Local version: $local_version" | ||
echo "NPM version: $npm_version" | ||
npm install -g semver | ||
|
||
if semver -r ">${npm_version}" "${local_version}"; then | ||
echo "Local version is greater than npm version: run release" | ||
echo "do-release=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "Local version is not greater than npm version: nothing to do." | ||
echo "do-release=false" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
publish-npm: | ||
runs-on: ubuntu-latest | ||
needs: check-versions | ||
if: ${{ needs.check-versions.outputs.do-release == 'true' }} | ||
environment: npm | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Run Unit Tests | ||
if: ${{ github.event.inputs.dry-run != 'true' }} | ||
run: | | ||
npm ci | ||
npm run test | ||
- name: Publish to npm | ||
run: npm publish --access public $DRY_RUN_OPTION | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} | ||
|
||
- name: Get Version | ||
id: get-version | ||
run: | | ||
echo "version=$(npm pkg get version | tr -d '"')" >> $GITHUB_OUTPUT | ||
- name: Parse CHANGELOG.md | ||
id: parse-changelog | ||
uses: schwma/[email protected] | ||
with: | ||
version: '${{ steps.get-version.outputs.version }}' | ||
title-regex: '^##\s+\[\d.*$' | ||
|
||
- name: Create a GitHub release | ||
if: ${{ github.event.inputs.dry-run != 'true' }} | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: 'v${{ steps.get-version.outputs.version }}' | ||
body: '${{ steps.parse-changelog.outputs.body }}' | ||
release: | ||
uses: cap-js/.github/.github/workflows/release.yml@main | ||
secrets: inherit | ||
with: | ||
dry-run: ${{ github.event.inputs.dry-run || false }} |