Skip to content

Commit 43fb412

Browse files
GHA-191 Add bump version functionality to automated release workflow (#99)
1 parent 979d64d commit 43fb412

File tree

2 files changed

+126
-106
lines changed

2 files changed

+126
-106
lines changed

.claude/skills/automated-release-setup/SKILL.md

Lines changed: 94 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Ask the user for the following details using AskUserQuestion:
2626
- **SLVSCode** (SonarLint for VS Code)
2727
- **SLE** (SonarLint for Eclipse)
2828
- **SLI** (SonarLint for IntelliJ)
29+
8. **Version Bump**: Whether the automated release workflow should bump the project version after the release (i.e., prepare the next development iteration). If yes, also ask:
30+
- **Bump Version PR Labels**: Optional comma-separated list of labels to apply to the version bump pull request (e.g., `update-next-dev,skip-qa`). Leave empty if no labels are needed.
2931

3032
### Step 1b: Check Existing release.yml
3133

@@ -34,6 +36,20 @@ Before asking for all information, read the existing `.github/workflows/release.
3436

3537
This ensures consistency between the release and automated-release workflows.
3638

39+
### Step 1c: Detect Workflow File Extension
40+
41+
Before creating any workflow files, check whether the existing workflows in `.github/workflows/` use `.yml` or `.yaml` as the file extension:
42+
43+
```bash
44+
ls .github/workflows/
45+
```
46+
47+
- If most existing files use `.yml`, create new workflow files with the `.yml` extension.
48+
- If most existing files use `.yaml`, create new workflow files with the `.yaml` extension.
49+
- If there is a mix, prefer `.yml` (GitHub Actions default).
50+
51+
Apply this detected extension consistently when naming all new workflow files (e.g., `automated-release.yml` or `automated-release.yaml`).
52+
3753
### Step 2: Check Prerequisites
3854

3955
Remind the user of these prerequisites and **ask for confirmation** using AskUserQuestion:
@@ -59,11 +75,9 @@ Remind the user of these prerequisites and **ask for confirmation** using AskUse
5975

6076
### Step 3: Create Workflow Files
6177

62-
Create two workflow files in `.github/workflows/`:
63-
64-
#### 3.1 Create `automated-release.yml`
78+
Create only the `automated-release` workflow file (using the detected extension from Step 1c). **Do not create a separate `bump-versions` workflow** — version bumping is handled directly by the reusable workflow when `bump-version: true` is passed.
6579

66-
**Standard workflow (SQS/SQC only):**
80+
#### 3.1 Create `automated-release{EXT}` (standard, no SonarLint, no version bump)
6781

6882
```yaml
6983
name: Automated Release
@@ -130,19 +144,82 @@ jobs:
130144
verbose: ${{ github.event.inputs.verbose == 'true' }}
131145
use-jira-sandbox: ${{ github.event.inputs.dry-run == 'true' }}
132146
is-draft-release: ${{ github.event.inputs.dry-run == 'true' }}
147+
```
148+
149+
#### 3.2 Create `automated-release{EXT}` (standard, no SonarLint, **with version bump**)
133150

134-
bump_versions:
135-
name: Bump versions
136-
needs: release
137-
uses: ./.github/workflows/bump-versions.yaml
151+
When the user wants version bumping, add `bump-version: true` (and optionally `bump-version-pr-lables`) to the `with:` block:
152+
153+
```yaml
154+
name: Automated Release
155+
on:
156+
workflow_dispatch:
157+
inputs:
158+
short-description:
159+
description: "Short description for the REL ticket"
160+
required: true
161+
type: string
162+
sqc-integration:
163+
description: "Integrate into SQC"
164+
type: boolean
165+
default: true
166+
sqs-integration:
167+
description: "Integrate into SQS"
168+
type: boolean
169+
default: true
170+
branch:
171+
description: "Branch from which to do the release"
172+
required: true
173+
default: "master"
174+
type: string
175+
new-version:
176+
description: "New version to release (without -SNAPSHOT; if left empty, the current minor version will be auto-incremented)"
177+
required: false
178+
type: string
179+
rule-props-changed:
180+
description: >
181+
"@RuleProperty" changed? See SC-4654
182+
type: boolean
183+
default: false
184+
verbose:
185+
description: "Enable verbose logging"
186+
type: boolean
187+
default: false
188+
dry-run:
189+
description: "Test mode: uses Jira sandbox and creates draft GitHub release"
190+
type: boolean
191+
default: false
192+
193+
jobs:
194+
release:
195+
name: Release
196+
uses: SonarSource/release-github-actions/.github/workflows/automated-release.yml@v1
138197
permissions:
198+
statuses: read
199+
id-token: write
139200
contents: write
201+
actions: write
140202
pull-requests: write
141203
with:
142-
version: ${{ needs.release.outputs.new-version }}
204+
project-name: "${PROJECT_NAME}"
205+
plugin-name: "${PLUGIN_NAME}"
206+
jira-project-key: "${JIRA_PROJECT_KEY}"
207+
rule-props-changed: ${{ github.event.inputs.rule-props-changed }}
208+
short-description: ${{ github.event.inputs.short-description }}
209+
new-version: ${{ github.event.inputs.new-version }}
210+
sqc-integration: ${{ github.event.inputs.sqc-integration == 'true' }}
211+
sqs-integration: ${{ github.event.inputs.sqs-integration == 'true' }}
212+
branch: ${{ github.event.inputs.branch }}
213+
pm-email: "${PM_EMAIL}"
214+
slack-channel: "${SLACK_CHANNEL}"
215+
verbose: ${{ github.event.inputs.verbose == 'true' }}
216+
use-jira-sandbox: ${{ github.event.inputs.dry-run == 'true' }}
217+
is-draft-release: ${{ github.event.inputs.dry-run == 'true' }}
218+
bump-version: true
219+
bump-version-pr-lables: "${BUMP_VERSION_PR_LABELS}" # omit this line if no labels
143220
```
144221

145-
**Workflow with SonarLint integration (includes IDE ticket creation):**
222+
#### 3.3 Create `automated-release{EXT}` (with SonarLint integration, no version bump)
146223

147224
```yaml
148225
name: Automated Release
@@ -234,99 +311,11 @@ jobs:
234311
verbose: ${{ github.event.inputs.verbose == 'true' }}
235312
use-jira-sandbox: ${{ github.event.inputs.dry-run == 'true' }}
236313
is-draft-release: ${{ github.event.inputs.dry-run == 'true' }}
237-
238-
bump_versions:
239-
name: Bump versions
240-
needs: release
241-
uses: ./.github/workflows/bump-versions.yaml
242-
permissions:
243-
contents: write
244-
pull-requests: write
245-
with:
246-
version: ${{ needs.release.outputs.new-version }}
247314
```
248315

249-
#### 3.2 Create `bump-versions.yaml`
250-
251-
**For Maven projects (pom.xml):**
316+
#### 3.4 Create `automated-release{EXT}` (with SonarLint integration **and** version bump)
252317

253-
```yaml
254-
name: bump-versions
255-
on:
256-
workflow_call:
257-
inputs:
258-
version:
259-
required: true
260-
type: string
261-
workflow_dispatch:
262-
inputs:
263-
version:
264-
description: The new version (without -SNAPSHOT)
265-
required: true
266-
type: string
267-
268-
jobs:
269-
bump-version:
270-
runs-on: sonar-xs
271-
permissions:
272-
contents: write
273-
pull-requests: write
274-
steps:
275-
- uses: actions/checkout@v4
276-
- env:
277-
VERSION: "${{ inputs.version }}-SNAPSHOT"
278-
run: |
279-
find . -type f -name "pom.xml" -exec sed -i "s/<version>.*-SNAPSHOT<\/version>/<version>${VERSION}<\/version>/" {} +
280-
- uses: peter-evans/create-pull-request@v7
281-
with:
282-
author: ${{ github.actor }} <${{ github.actor }}>
283-
commit-message: Prepare next development iteration
284-
title: Prepare next development iteration
285-
branch: bot/bump-project-version
286-
branch-suffix: timestamp
287-
base: master
288-
reviewers: ${{ github.actor }}
289-
```
290-
291-
**For Gradle projects (gradle.properties):**
292-
293-
```yaml
294-
name: bump-versions
295-
on:
296-
workflow_call:
297-
inputs:
298-
version:
299-
required: true
300-
type: string
301-
workflow_dispatch:
302-
inputs:
303-
version:
304-
description: The new version (without -SNAPSHOT)
305-
required: true
306-
type: string
307-
308-
jobs:
309-
bump-version:
310-
runs-on: sonar-xs
311-
permissions:
312-
contents: write
313-
pull-requests: write
314-
steps:
315-
- uses: actions/checkout@v4
316-
- env:
317-
VERSION: "${{ inputs.version }}-SNAPSHOT"
318-
run: |
319-
sed -i "s/version=.*-SNAPSHOT/version=${VERSION}/" gradle.properties
320-
- uses: peter-evans/create-pull-request@v7
321-
with:
322-
author: ${{ github.actor }} <${{ github.actor }}>
323-
commit-message: Prepare next development iteration
324-
title: Prepare next development iteration
325-
branch: bot/bump-project-version
326-
branch-suffix: timestamp
327-
base: master
328-
reviewers: ${{ github.actor }}
329-
```
318+
Add `bump-version: true` (and optionally `bump-version-pr-lables`) to the SonarLint variant's `with:` block, same as in 3.2.
330319

331320
### Step 4: Update release.yml
332321

@@ -382,15 +371,14 @@ After creating/modifying all workflow files, create a branch and commit the chan
382371
# Create a new branch
383372
git checkout -b add-automated-release-workflow
384373
385-
# Stage the workflow files
386-
git add .github/workflows/automated-release.yml .github/workflows/bump-versions.yaml .github/workflows/release.yml
374+
# Stage the workflow files (use the correct extension detected in Step 1c)
375+
git add .github/workflows/automated-release.yml .github/workflows/release.yml
387376
388377
# Commit with descriptive message
389378
git commit -m "Add automated release workflow
390379
391-
Add workflows for automated release process:
380+
Add workflow for automated release process:
392381
- automated-release.yml: Main workflow that orchestrates the release
393-
- bump-versions.yaml: Bumps version file after release
394382
- Update release.yml to support workflow_dispatch for automated releases
395383
"
396384
```
@@ -460,7 +448,7 @@ Provide these instructions to the user:
460448
### Step 7: Post-Release Checklist
461449

462450
Remind user of post-release tasks:
463-
- Review and merge the bump-version PR
451+
- Review and merge the bump-version PR (if version bumping was enabled)
464452
- Review and merge the SQS PR in sonar-enterprise
465453
- Review and merge the SQC PR in sonarcloud-core
466454
- Update integration ticket statuses in Jira
@@ -504,4 +492,4 @@ The `sq-ide-short-description` input is used as the description for all IDE tick
504492

505493
- Setup Guide: https://github.com/SonarSource/release-github-actions/blob/master/docs/SETUP_AUTOMATED_RELEASE.md
506494
- Workflow Documentation: https://github.com/SonarSource/release-github-actions/blob/master/docs/AUTOMATED_RELEASE.md
507-
- Example: https://github.com/SonarSource/sonar-abap/blob/master/.github/workflows/automated-release.yml
495+
- Example: https://github.com/SonarSource/sonar-abap/blob/master/.github/workflows/automated-release.yml

.github/workflows/automated-release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ on:
130130
required: false
131131
type: string
132132
default: "Feature,False Positive,False Negative,Bug,Security"
133+
bump-version:
134+
description: "Whether to bump the version after the release. If false, the workflow will just output the next version without modifying any files."
135+
required: false
136+
type: boolean
137+
default: false
138+
bump-version-pr-lables:
139+
description: "Labels to apply to the version bump pull request if bump-version is true. For example, 'update-next-dev,skip-qa'."
140+
required: false
141+
type: string
142+
bump-version-exlusions:
143+
description: "Comma-separated list of module to exclude from the version bump commit."
144+
required: false
145+
type: string
133146

134147
outputs:
135148
new-version:
@@ -458,6 +471,25 @@ jobs:
458471
echo "### Results" >> $GITHUB_STEP_SUMMARY
459472
echo "- New Jira version: \`${{ steps.create-jira-version.outputs.jira-new-version-name }}\`." >> $GITHUB_STEP_SUMMARY
460473
474+
# This step bumps the version in the codebase and creates a pull request for the next development iteration.
475+
bump-version:
476+
name: Bump Version
477+
needs: [ release-in-jira ]
478+
if: ${{ inputs.bump-version }}
479+
runs-on: ${{ inputs.runner-environment }}
480+
permissions:
481+
id-token: write
482+
contents: write
483+
pull-requests: write
484+
steps:
485+
- name: Bump version and create PR
486+
uses: SonarSource/release-github-actions/bump-version@v1
487+
with:
488+
version: ${{ needs.release-in-jira.outputs.new-version }}
489+
pr-labels: ${{ inputs.bump-version-pr-lables }}
490+
excluded-modules: ${{ inputs.bump-version-exlusions }}
491+
base-branch: ${{ inputs.branch }}
492+
461493
# This step creates integration tickets in various Jira projects based on the inputs provided.
462494
# It creates tickets for SLVS, SLVSCODE, SLE, SLI, SQC, and SQS as specified.
463495
# It outputs the integration ticket keys for SQC and SQS for further use.

0 commit comments

Comments
 (0)