Skip to content

Commit

Permalink
Try adding CI inputs to define whether a major version shall be released
Browse files Browse the repository at this point in the history
Co-authored-by: Mukul Mishra <[email protected]>
Co-authored-by: Giuseppe Samela <[email protected]>
  • Loading branch information
3 people committed Dec 5, 2024
1 parent 333dbd7 commit 425804b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
8 changes: 6 additions & 2 deletions .github/scripts/defineVersion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const parseChangelog = require('changelog-parser');
const semver = require('semver');

async function defineReleaseVersion({ core }, currentVersion, changelogFile) {
async function defineReleaseVersion({ core }, currentVersion, changelogFile, isMajorRelease) {
return parseChangelog(changelogFile).then((result) => {
const unreleased = result.versions.find((entry) => entry.version === null);

Expand All @@ -20,7 +20,11 @@ async function defineReleaseVersion({ core }, currentVersion, changelogFile) {
const hasSecurityEntries = parsedSections.Security && parsedSections.Security.length > 0;
const hasDeprecatedEntries = parsedSections.Deprecated && parsedSections.Deprecated.length > 0;

if (hasAddedSection || hasChangedSection || hasRemovedSection) {
if (isMajorRelease) {
const version = semver.inc(currentVersion, 'major');
core.info(`Increase version from ${currentVersion} to ${version}`);
return version;
} else if (hasAddedSection || hasChangedSection || hasRemovedSection) {
const version = semver.inc(currentVersion, 'minor');
core.info(`Increase version from ${currentVersion} to ${version}`);
return version;
Expand Down
58 changes: 32 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Release new version

on:
workflow_dispatch:
inputs:
is-major-release:
type: boolean
description: Is this a major release?
required: false
default: false

jobs:
release:
Expand Down Expand Up @@ -47,30 +53,30 @@ jobs:
with:
script: |
const { defineReleaseVersion } = require('./.github/scripts/defineVersion.js')
return defineReleaseVersion({core}, "${{ steps.read-latest-release-version.outputs.latestReleaseVersion }}", './CHANGELOG.md' )
return defineReleaseVersion({core}, "${{ steps.read-latest-release-version.outputs.latestReleaseVersion }}", './CHANGELOG.md', ${{ inputs.is-major-release }})
- name: Bump package.json and Changelog version
run: |
npm --no-git-tag-version version "${{ fromJson(steps.define-release-version.outputs.result) }}"
npx kacl release
- name: Add tag and push changes
run: |
git config --global user.name 'Automated Release'
git config --global user.email '[email protected]'
git add .
git commit -m "Bump version and update changelog"
git tag -a "${{ fromJson(steps.define-release-version.outputs.result) }}" -m "v${{ fromJson(steps.define-release-version.outputs.result) }}"
git push origin develop
git push origin --tags
- name: build and publish
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
npm publish
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
tag_name: ${{ fromJson(steps.define-release-version.outputs.result) }}
# - name: Bump package.json and Changelog version
# run: |
# npm --no-git-tag-version version "${{ fromJson(steps.define-release-version.outputs.result) }}"
# npx kacl release
#
# - name: Add tag and push changes
# run: |
# git config --global user.name 'Automated Release'
# git config --global user.email '[email protected]'
# git add .
# git commit -m "Bump version and update changelog"
# git tag -a "${{ fromJson(steps.define-release-version.outputs.result) }}" -m "v${{ fromJson(steps.define-release-version.outputs.result) }}"
# git push origin develop
# git push origin --tags
#
# - name: build and publish
# run: |
# echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
# npm publish
#
# - name: Create GitHub release
# uses: softprops/action-gh-release@v2
# with:
# generate_release_notes: true
# tag_name: ${{ fromJson(steps.define-release-version.outputs.result) }}

0 comments on commit 425804b

Please sign in to comment.