Skip to content

Commit 1283949

Browse files
Release automation workflow (#670)
Co-authored-by: Maksim Grebeniuk <maksim.grebeniuk@sonarsource.com>
1 parent ac591f6 commit 1283949

File tree

3 files changed

+158
-1
lines changed

3 files changed

+158
-1
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Automate release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
short-description:
7+
description: |
8+
A brief summary of what the release contains.
9+
This will be added directly to the release ticket.
10+
required: true
11+
rule-props-changed:
12+
type: choice
13+
description: |
14+
Did any rule properties change in this release?
15+
required: true
16+
default: "No"
17+
options:
18+
- "Yes"
19+
- "No"
20+
branch:
21+
description: |
22+
Branch from which to do the release.
23+
required: true
24+
default: "master"
25+
release-notes:
26+
description: |
27+
Release notes.
28+
If blank, release notes will be generated from the Jira Release.
29+
sq-ide-short-description:
30+
description: |
31+
A brief summary of SQ IDE related changes.
32+
If blank, the generic brief summary defined above will be used.
33+
new-version:
34+
description: |
35+
Specify the version for the next release (e.g., 4.2.0).
36+
If left blank, the last version number will be automatically incremented (e.g., 1.51 -> 1.52, 1.51.1 -> 1.51.2).
37+
require-rule-metadata-update:
38+
type: boolean
39+
description: |
40+
Toggle whether the pre release checks should include a rule metadata update.
41+
It is false for now as the action is broken, because of RSPEC repo went private, see GHA-184 for more details.
42+
default: false
43+
dry-run:
44+
description: "Test mode: uses Jira sandbox and creates draft GitHub release"
45+
type: boolean
46+
default: false
47+
48+
jobs:
49+
lock-branch:
50+
name: Lock ${{ inputs.branch }} branch
51+
uses: ./.github/workflows/ToggleLockBranch.yml
52+
permissions:
53+
id-token: write
54+
with:
55+
branch: ${{ inputs.branch }}
56+
57+
release:
58+
name: Release
59+
uses: SonarSource/release-github-actions/.github/workflows/cloud-security-automated-release.yml@v1
60+
needs: lock-branch
61+
permissions:
62+
statuses: read
63+
id-token: write
64+
contents: write
65+
actions: write
66+
pull-requests: write
67+
with:
68+
jira-project-key: "SONARKT"
69+
project-name: "SonarKotlin"
70+
plugin-name: "kotlin"
71+
plugin-artifacts-sqs: "kotlin"
72+
plugin-artifacts-sqc: "kotlin"
73+
use-jira-sandbox: ${{ github.event.inputs.dry-run == 'true' }}
74+
is-draft-release: ${{ github.event.inputs.dry-run == 'true' }}
75+
pm-email: "alexandre.gigleux@sonarsource.com"
76+
release-automation-secret-name: "sonar-kotlin-release-automation"
77+
short-description: ${{ inputs.short-description }}
78+
rule-props-changed: ${{ inputs.rule-props-changed }}
79+
branch: ${{ inputs.branch }}
80+
release-notes: ${{ inputs.release-notes }}
81+
sq-ide-short-description: ${{ inputs.sq-ide-short-description }}
82+
new-version: ${{ inputs.new-version }}
83+
create-slvs-ticket: false
84+
create-sle-ticket: false
85+
require-rule-metadata-update: ${{ inputs.require-rule-metadata-update }}
86+
87+
unlock-branch:
88+
name: Unlock ${{ inputs.branch }} branch
89+
uses: ./.github/workflows/ToggleLockBranch.yml
90+
needs: release
91+
permissions:
92+
id-token: write
93+
with:
94+
branch: ${{ inputs.branch }}
95+
96+
bump_versions:
97+
name: Bump versions
98+
needs: [release, unlock-branch]
99+
uses: ./.github/workflows/bump-versions.yaml
100+
permissions:
101+
contents: write
102+
pull-requests: write
103+
with:
104+
version: ${{ needs.release.outputs.new-version }}-SNAPSHOT
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Toggle lock branch
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
required: true
8+
type: string
9+
default: "master"
10+
workflow_dispatch: # Triggered manually from the GitHub UI / Actions
11+
inputs:
12+
branch:
13+
description: "Branch to to toggle lock on"
14+
required: true
15+
default: "master"
16+
17+
jobs:
18+
ToggleLockBranch_job:
19+
name: Toggle lock branch
20+
runs-on: github-ubuntu-latest-s
21+
permissions:
22+
id-token: write
23+
steps:
24+
- id: secrets
25+
uses: SonarSource/vault-action-wrapper@v3
26+
with:
27+
secrets: |
28+
development/github/token/{REPO_OWNER_NAME_DASH}-lock token | lock_token;
29+
development/kv/data/slack token | slack_api_token;
30+
- uses: sonarsource/gh-action-lt-backlog/ToggleLockBranch@v2
31+
with:
32+
github-token: ${{ fromJSON(steps.secrets.outputs.vault).lock_token }}
33+
slack-token: ${{ fromJSON(steps.secrets.outputs.vault).slack_api_token }}
34+
slack-channel: squad-security-cloud-notifs
35+
branch-pattern: ${{ inputs.branch }}

.github/workflows/release.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
---
2-
name: release
2+
name: sonar-release
33
# This workflow is triggered when publishing a new github release
44
# yamllint disable-line rule:truthy
55
on:
66
release:
77
types:
88
- published
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
type: string
13+
description: Version
14+
required: true
15+
releaseId:
16+
type: string
17+
description: Release ID
18+
required: true
19+
dryRun:
20+
type: boolean
21+
description: Flag to enable the dry-run execution
22+
default: false
23+
required: false
924

1025
jobs:
1126
release:
@@ -14,6 +29,9 @@ jobs:
1429
contents: write
1530
uses: SonarSource/gh-action_release/.github/workflows/main.yaml@v6
1631
with:
32+
version: ${{ inputs.version }}
33+
releaseId: ${{ inputs.releaseId }}
34+
dryRun: ${{ inputs.dryRun }}
1735
publishToBinaries: true
1836
mavenCentralSync: true
1937
slackChannel: squad-security-cloud-notifs

0 commit comments

Comments
 (0)