Skip to content

Commit 7889935

Browse files
GHA-171 Add automated release setup guide for SonarSource analyzer projects (#80)
1 parent 50a2bb9 commit 7889935

File tree

1 file changed

+298
-0
lines changed

1 file changed

+298
-0
lines changed

docs/SETUP_AUTOMATED_RELEASE.md

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# Setting Up Automated Release for Your Repository
2+
3+
This guide walks through setting up the automated release workflow for a SonarSource analyzer project.
4+
5+
For detailed workflow documentation (inputs, outputs, behavior), see [AUTOMATED_RELEASE.md](AUTOMATED_RELEASE.md).
6+
7+
## Prerequisites Checklist
8+
9+
Before the workflow will work, complete these steps:
10+
11+
### Jira Configuration
12+
13+
- [ ] **Add `Jira Tech User GitHub` as Administrator** on your Jira project (required to create/release versions)
14+
- [ ] **Add the same user to Jira sandbox** if testing with `dry-run: true`
15+
16+
### Vault Permissions (re-terraform-aws-vault)
17+
18+
- [ ] **Create PR to add release-automation permission** for analyzer PR creation
19+
20+
Example for `orders/{squad}.yaml`:
21+
```yaml
22+
- <<: *release_automation
23+
repositories: [your-repo, sonar-enterprise, sonarcloud-core]
24+
```
25+
26+
The secret name defaults to `sonar-{plugin-name}-release-automation`.
27+
28+
See example PR: https://github.com/SonarSource/re-terraform-aws-vault/pull/8406
29+
30+
## Information Needed
31+
32+
Before creating the workflows, gather:
33+
34+
1. **Project Identity:**
35+
- Jira project key (e.g., SONARARMOR, CSD, SLCORE)
36+
- Display name (e.g., "SonarArmor", "SonarJava")
37+
- Plugin name (e.g., "armor", "csd")
38+
39+
2. **Team & Workflow:**
40+
- Product Manager email (for ticket assignment after release)
41+
- Slack channel for notifications
42+
- Release branch (usually `master`)
43+
44+
3. **Integrations:**
45+
- SonarQube Server integration? (creates PRs in sonar-enterprise, tickets in SONAR project)
46+
- SonarCloud integration? (creates PRs in sonarcloud-core, tickets in SC project)
47+
- IDE tickets needed? (SLVS, SLVSCODE, SLE, SLI)
48+
49+
## Create the Workflows
50+
51+
### 1. `.github/workflows/automated-release.yml`
52+
53+
```yaml
54+
# Automated Release Workflow
55+
#
56+
# This workflow automates the complete release process including:
57+
# - Creating Jira release tickets and managing versions
58+
# - Publishing GitHub releases
59+
# - Creating integration tickets for SQC and SQS
60+
# - Updating analyzers with the new version
61+
# - Bumping version numbers for the next development cycle
62+
#
63+
# Usage:
64+
# - Trigger manually via GitHub Actions UI
65+
# - Set 'dry-run: true' to use Jira sandbox and create draft releases (for testing)
66+
# - Set 'dry-run: false' for production releases
67+
68+
name: Automated Release
69+
70+
on:
71+
workflow_dispatch:
72+
inputs:
73+
short-description:
74+
description: "Short description for the REL ticket"
75+
required: true
76+
type: string
77+
sqc-integration:
78+
description: "Integrate into SQC"
79+
type: boolean
80+
default: true
81+
sqs-integration:
82+
description: "Integrate into SQS"
83+
type: boolean
84+
default: true
85+
branch:
86+
description: "Branch from which to do the release"
87+
required: true
88+
default: "master"
89+
type: string
90+
new-version:
91+
description: "New version (without -SNAPSHOT; leave empty to auto-increment minor)"
92+
required: false
93+
type: string
94+
rule-props-changed:
95+
description: '"@RuleProperty" changed? See SC-4654'
96+
type: boolean
97+
default: false
98+
dry-run:
99+
description: "Use Jira sandbox and create draft releases (true) or production (false)"
100+
type: boolean
101+
default: false
102+
103+
jobs:
104+
release:
105+
name: Release
106+
uses: SonarSource/release-github-actions/.github/workflows/automated-release.yml@v1
107+
permissions:
108+
statuses: read
109+
id-token: write
110+
contents: write
111+
actions: write
112+
pull-requests: write
113+
with:
114+
project-name: "YOUR_PROJECT_NAME" # e.g., "SonarArmor"
115+
plugin-name: "your-plugin" # e.g., "armor"
116+
jira-project-key: "YOUR_JIRA_KEY" # e.g., "SONARARMOR"
117+
rule-props-changed: ${{ github.event.inputs.rule-props-changed }}
118+
short-description: ${{ github.event.inputs.short-description }}
119+
new-version: ${{ github.event.inputs.new-version }}
120+
sqc-integration: ${{ github.event.inputs.sqc-integration == 'true' }}
121+
sqs-integration: ${{ github.event.inputs.sqs-integration == 'true' }}
122+
branch: ${{ github.event.inputs.branch }}
123+
pm-email: "pm@sonarsource.com" # Product Manager email
124+
slack-channel: "your-slack-channel"
125+
verbose: true
126+
use-jira-sandbox: ${{ github.event.inputs.dry-run == 'true' }}
127+
is-draft-release: ${{ github.event.inputs.dry-run == 'true' }}
128+
129+
bump_versions:
130+
name: Bump versions
131+
needs: release
132+
uses: ./.github/workflows/bump-version.yml
133+
permissions:
134+
contents: write
135+
pull-requests: write
136+
with:
137+
version: ${{ needs.release.outputs.new-version }}
138+
```
139+
140+
### 2. `.github/workflows/bump-version.yml`
141+
142+
```yaml
143+
name: Bump version
144+
145+
on:
146+
workflow_dispatch:
147+
inputs:
148+
version:
149+
description: "Next version (e.g., 1.2.0) or leave empty to auto-increment minor"
150+
type: string
151+
create-pull-request:
152+
description: "Create a Pull Request"
153+
type: boolean
154+
default: true
155+
workflow_call:
156+
inputs:
157+
version:
158+
type: string
159+
160+
jobs:
161+
bump-version:
162+
runs-on: ubuntu-latest
163+
permissions:
164+
contents: write
165+
pull-requests: write
166+
steps:
167+
- uses: actions/checkout@v4
168+
169+
- name: Get Next Version
170+
id: get_next_version
171+
env:
172+
INPUT_VERSION: ${{ inputs.version }}
173+
run: |
174+
if [ -n "$INPUT_VERSION" ]; then
175+
next_version="$INPUT_VERSION"
176+
echo "Using provided version: $next_version"
177+
else
178+
# Extract version from gradle.properties
179+
raw_version=$(grep -oPm1 "(?<=version=).*-SNAPSHOT" gradle.properties)
180+
current_version="$(echo "$raw_version" | sed 's/-SNAPSHOT//')"
181+
182+
if [[ -z "$current_version" ]]; then
183+
echo "::error::Failed to extract version from gradle.properties"
184+
exit 1
185+
fi
186+
187+
# Increment minor version, reset patch to 0
188+
next_version=$(echo $current_version | awk -F. -v OFS=. '{$2++; $3=0; print}')
189+
echo "Auto-incremented to: $next_version"
190+
fi
191+
192+
echo "next-version=$next_version" >> $GITHUB_OUTPUT
193+
echo "NEXT_VERSION=$next_version" >> $GITHUB_ENV
194+
195+
- name: Update Version
196+
if: ${{ inputs.create-pull-request != false }}
197+
run: |
198+
snapshot_version="${NEXT_VERSION}-SNAPSHOT"
199+
sed -i "s/version=.*-SNAPSHOT/version=${snapshot_version}/" gradle.properties
200+
201+
- name: Create Pull Request
202+
if: ${{ inputs.create-pull-request != false }}
203+
uses: peter-evans/create-pull-request@v7
204+
with:
205+
commit-message: "Bump version to ${{ env.NEXT_VERSION }}"
206+
branch: "bump-version-to-${{ env.NEXT_VERSION }}"
207+
title: "Bump version to ${{ env.NEXT_VERSION }}"
208+
body: "This PR bumps the project version to ${{ env.NEXT_VERSION }}."
209+
reviewers: ${{ github.actor }}
210+
211+
- name: Summary
212+
run: |
213+
echo "## Version Bump Summary" >> $GITHUB_STEP_SUMMARY
214+
echo "Next version: ${{ env.NEXT_VERSION }}" >> $GITHUB_STEP_SUMMARY
215+
```
216+
217+
### 3. Update existing `.github/workflows/release.yml`
218+
219+
Add `workflow_dispatch` support for manual triggering (needed for the automated release to trigger artifact publishing):
220+
221+
```yaml
222+
on:
223+
release:
224+
types:
225+
- published
226+
workflow_dispatch:
227+
inputs:
228+
version:
229+
type: string
230+
description: Version
231+
required: true
232+
releaseId:
233+
type: string
234+
description: Release ID
235+
required: true
236+
dryRun:
237+
type: boolean
238+
description: Do not publish artifacts
239+
default: false
240+
241+
jobs:
242+
release:
243+
# ... existing job config ...
244+
uses: SonarSource/gh-action_release/.github/workflows/main.yaml@v6
245+
with:
246+
version: ${{ inputs.version }}
247+
releaseId: ${{ inputs.releaseId }}
248+
dryRun: ${{ inputs.dryRun }}
249+
# ... other existing inputs ...
250+
```
251+
252+
## Testing the Setup
253+
254+
1. **First test with dry-run**: Run the automated-release workflow with `dry-run: true`
255+
- This uses Jira sandbox and creates draft GitHub releases
256+
- Verify tickets are created in Jira sandbox
257+
- Verify PRs are created as drafts
258+
259+
2. **Production release**: Once validated, run with `dry-run: false`
260+
261+
## Example Implementation
262+
263+
See the sonar-armor implementation: https://github.com/SonarSource/sonar-armor/pull/1253
264+
265+
## Common Customizations
266+
267+
### Custom Plugin Artifacts
268+
269+
If SQS and SQC use different artifact names:
270+
```yaml
271+
plugin-artifacts-sqs: "your-sqs-artifact"
272+
plugin-artifacts-sqc: "your-sqc-artifact"
273+
```
274+
275+
### Custom Release Automation Secret
276+
277+
If not using the default `sonar-{plugin-name}-release-automation`:
278+
```yaml
279+
release-automation-secret-name: "custom-secret-name"
280+
```
281+
282+
### IDE Integration Tickets
283+
284+
Enable creation of tickets for IDE teams:
285+
```yaml
286+
create-slvs-ticket: true
287+
create-slvscode-ticket: true
288+
create-sle-ticket: true
289+
create-sli-ticket: true
290+
sq-ide-short-description: "Changes relevant to IDE integrations"
291+
```
292+
293+
### Runner Environment
294+
295+
Specify a different runner:
296+
```yaml
297+
runner-environment: "sonar-s"
298+
```

0 commit comments

Comments
 (0)