@@ -6,12 +6,13 @@ This guide shows how to implement automated releases using the reusable GitHub A
66
77* [ About Reusable Workflows] ( #about-reusable-workflows )
88* [ Prerequisite: Vault Secrets] ( #prerequisite-vault-secrets )
9+ * [ Prerequisite: Jira Sandbox] ( #prerequisite-jira-sandbox )
910* [ Implementation Steps] ( #implementation-steps )
10- * [ Phase 1: Create Supporting Workflows] ( #phase-1-create-supporting-workflows )
11- * [ Phase 2: Create Placeholder Workflow] ( #phase-2-create-placeholder-workflow )
12- * [ Phase 3: Integrate with Reusable Workflow] ( #phase-3-integrate-with -reusable-workflow )
13- * [ Phase 4: Test and Refine ] ( #phase-4-test-and-refine )
14- * [ Real Examples ] ( #real-examples )
11+ * [ Phase 1: Create Supporting Workflows] ( #phase-1-create-supporting-workflows )
12+ * [ Phase 2: Create Placeholder Workflow] ( #phase-2-create-placeholder-workflow )
13+ * [ Phase 3: Create Your Reusable Workflow] ( #phase-3-create-your -reusable-workflow )
14+ * [ Phase 4: Integrate with Reusable Workflow ] ( #phase-4-integrate-with-reusable-workflow )
15+ * [ Phase 5: Test and Refine ] ( #phase-5-test-and-refine )
1516* [ Resources] ( #resources )
1617
1718## About Reusable Workflows
@@ -34,19 +35,26 @@ Here are two examples:
3435* [ PR for ABD repositories] ( https://github.com/SonarSource/re-terraform-aws-vault/pull/7729 )
3536* [ PR for Cloud Security repositories] ( https://github.com/SonarSource/re-terraform-aws-vault/pull/6693 )
3637
38+ ## Prerequisite: Jira Sandbox
39+
40+ To test the release automation in a safe manner, you should ensure the following:
41+
42+ 1 . You can open the [ Jira sandbox] ( https://sonarsource-sandbox-608.atlassian.net/jira ) .
43+ 2 . You have (admin) access to your analyzer project in the sandbox and you can create versions and tickets there.
44+
3745## Implementation Steps
3846
3947### Phase 1: Create Supporting Workflows
4048
41- In this phase we will add workflows to check releasability, to update metadata, and to bump analyzer versions.
42- If your repository already contains some of these workflows, feel free to skip steps .
49+ In this phase we will add workflows to check releasability, to update metadata, to bump analyzer versions, etc .
50+ If your repository already contains some of these workflows, double-check that they match the requirements below .
4351
4452#### 1.1 Releasability Status
4553
4654[ // ] : # ( @formatter:off )
4755
4856* Copy
49- [ ABD's releaseability- status.yml ] ( https://github.com/SonarSource/sonar-dataflow-bug-detection/blob/master /.github/workflows/releaseability-status .yml )
57+ [ ABD's releaseability status check ] ( https://github.com/SonarSource/sonar-dataflow-bug-detection/blob/8764808bd7622a70f2320a1b9874e58c6e477bf3 /.github/workflows/build .yml#L226 )
5058 to your repositories.
5159* Check if anything needs to be adapted to your repository. Though, it should work for most analyzers as-is.
5260
@@ -83,6 +91,47 @@ If your repository already contains some of these workflows, feel free to skip s
8391 ` ` `
8492* Check if anything else needs to be adapted to your repository.
8593
94+ **Pay special attention** that it can take a specific branch as input and that a ` workflow_call` trigger is configured as in the given
95+ examples.
96+ The branch input must be passed on to the `sonarsource/gh-action-lt-backlog/ToggleLockBranch` action as a `branch_pattern` parameter.
97+ See the given example.
98+
99+ # ### 1.5 Release Action
100+
101+ * We assume that a release action similar to
102+ [DBD's release action](https://github.com/SonarSource/sonar-dataflow-bug-detection/blob/154aeb888d290afbc36f584e415d6608986eb65b/.github/workflows/release.yml)
103+ is already in place.
104+ * However, make sure that you are using at least version 6 of the release workflow:
105+ ` SonarSource/gh-action_release/.github/workflows/main.yaml@v6`
106+ * Also, a `workflow_dispatch` trigger with three inputs must be present:
107+ ` ` ` yml
108+ workflow_dispatch:
109+ inputs:
110+ version:
111+ type: string
112+ description: Version
113+ required: true
114+ releaseId:
115+ type: string
116+ description: Release ID
117+ required: true
118+ dryRun:
119+ type: boolean
120+ description: Flag to enable the dry-run execution
121+ default: false
122+ required: false
123+ ` ` `
124+ and these inputs must be passed on to the release action :
125+ ` ` ` yml
126+ # [...]
127+ uses: SonarSource/gh-action_release/.github/workflows/main.yaml@v6
128+ with:
129+ # [...]
130+ version: ${{ inputs.version }}
131+ releaseId: ${{ inputs.releaseId }}
132+ dryRun: ${{ inputs.dryRun }}
133+ ` ` `
134+
86135[//] : # (@formatter:on)
87136
88137# ## Phase 2: Create Placeholder Workflow
@@ -130,91 +179,60 @@ jobs:
130179 run: echo "Testing workflow inputs"
131180` ` `
132181
133- Test this manually from GitHub UI to ensure inputs appear correctly.
134-
135- # ## Phase 3: Integrate with Reusable Workflow
136-
137- Replace the `jobs` section in `.github/workflows/AutomateRelease.yml` with :
138-
139- ` ` ` yaml
140- jobs:
141- lock-branch:
142- name: Lock ${{ inputs.branch }} branch
143- uses: ./.github/workflows/ToggleLockBranch.yml
144- permissions:
145- id-token: write
146- with:
147- branch: ${{ inputs.branch }}
148-
149- release:
150- name: Release
151- uses: SonarSource/release-github-actions/.github/workflows/abd-automated-release.yml@v1
152- needs: lock-branch
153- permissions:
154- statuses: read
155- id-token: write
156- contents: write
157- actions: write
158- pull-requests: write
159- with:
160- # TODO: Customize these values for your project
161- jira-project-key: "DBD" # Your Jira project key
162- project-name: "SonarDBD" # Your project display name
163- plugin-artifacts: "dbd,dbd-java-frontend,dbd-python-frontend" # Comma-separated artifacts
164- use-jira-sandbox: true # Set false for production
165- is-draft-release: true # Set false for production
166- pm-email: "pm@sonarsource.com" # Product manager email
167- release-automation-secret-name: "your-project-release-automation" # Your Vault secret
168-
169- # Pass through user inputs
170- short-description: ${{ inputs.short-description }}
171- rule-props-changed: ${{ inputs.rule-props-changed }}
172- branch: ${{ inputs.branch }}
173- release-notes: ${{ inputs.release-notes }}
174- new-version: ${{ inputs.new-version }}
175-
176- unlock-branch:
177- name: Unlock ${{ inputs.branch }} branch
178- uses: ./.github/workflows/ToggleLockBranch.yml
179- needs: release
180- permissions:
181- id-token: write
182- with:
183- branch: ${{ inputs.branch }}
184-
185- bump_versions:
186- name: Bump versions
187- needs: [ release, unlock-branch ]
188- uses: ./.github/workflows/bump-versions.yaml
189- permissions:
190- contents: write
191- pull-requests: write
192- with:
193- version: ${{ needs.release.outputs.new-version }}
194- ` ` `
195-
196- **See complete example**:
197- [sonar-dataflow-bug-detection/AutomateRelease.yml](https://github.com/SonarSource/sonar-dataflow-bug-detection/blob/master/.github/workflows/AutomateRelease.yml)
198-
199- # ## Phase 4: Test and Refine
200-
201- 1. **Initial test** : Use `use-jira-sandbox: true` and `is-draft-release: true`
202- 2. **Verify outputs** : Check Jira sandbox for tickets, draft GitHub release, PRs for SQS/SQC/version-bump
203- 3. **If testing with unreleased workflow** : Use `@branch-name` instead of `@v1`, switch after merge
204- 4. **Production** : Set `use-jira-sandbox: false` and `is-draft-release: false`
205-
206- # ## Real Examples
207-
208- **DBD**:
209- [AutomateRelease.yml](https://github.com/SonarSource/sonar-dataflow-bug-detection/blob/master/.github/workflows/AutomateRelease.yml)
210-
211- * Uses [`abd-automated-release.yml`](../.github/workflows/abd-automated-release.yml) workflow
212-
213- **Cloud Security**:
214- SonarIaC's [AutomateRelease.yml](https://github.com/SonarSource/sonar-iac-enterprise/blob/master/.github/workflows/AutomateRelease.yml)
215-
216- * Uses [`cloud-security-automated-release.yml`](../.github/workflows/cloud-security-automated-release.yml) - Different
217- workflow with separate SQS/SQC artifacts and SonarLint integration
182+ # ## Phase 3: Create Your Reusable Workflow
183+
184+ * Create a file for your reusable flow at `.github/workflows/<squad-name>-automated-release.yml`.
185+ * You can use one of the following workflows as a template:
186+ * [ABD's workflow](https://github.com/SonarSource/release-github-actions/blob/master/.github/workflows/abd-automated-release.yml)
187+ * [Cloud Security's workflow](https://github.com/SonarSource/release-github-actions/blob/master/.github/workflows/cloud-security-automated-release.yml)
188+ * This one is considering SonarLint integrations!
189+ * The templates should work for you as-is, but only you know your squad's specific needs.
190+ Hence, study the workflow and adapt it as needed.
191+ * Upload your changes as a PR. You do not need to get it merged before you are done testing everything.
192+
193+ # ## Phase 4: Integrate with Reusable Workflow
194+
195+ > [!IMPORTANT]
196+ > **Make sure everything that was created in the phases 1 and 2 is merged.**
197+ >
198+ > However, the changes below can be tested on a PR branch before merging because of the placeholder workflow that we have added.
199+ > When testing, make sure to follow the dry-run guidelines in Phase 5.
200+
201+ 1. Replace the placeholder workflow in `.github/workflows/AutomateRelease.yml`.
202+ Use the contents of one of the following `AutomateRelease.yml` implementations as a basis.
203+ * [DBD's AutomateRelease.yml](https://github.com/SonarSource/sonar-dataflow-bug-detection/blob/master/.github/workflows/AutomateRelease.yml)
204+ * [Cloud Security's AutomateRelease.yml](https://github.com/SonarSource/sonar-iac-enterprise/blob/master/.github/workflows/AutomateRelease.yml)
205+ * This one has SonarLint integrations
206+ 2. Replace the call to the `abd-automated-release.yml` or `cloud-security-automated-release.yml` template workflow with the name of the
207+ reusable workflow that you created in Phase 3.
208+ If your reusable workflow is not yet merged, you might also need to use the last commit hash of your PR branch instead of the version.
209+ 3. Adapt the following arguments to fit your project :
210+ ` ` ` yml
211+ jira-project-key: "<...>"
212+ project-name: "<...>"
213+ plugin-artifacts: "<All artifacts (your plugins!) that need to be released, comma-separated>"
214+ pm-email: "mail.of.your.pm@sonarsource.com"
215+ release-automation-secret-name: "<name of the secret you created in Phase 1>"
216+ ` ` `
217+
218+ These are the parameters of ABD's reusable workflow.
219+ Depending on whether you used ABD's or Cloud Security's reusable workflow as a base, you might have to adapt additional parameters and
220+ the parameter names are slightly different.
221+ 4. Create a PR on your project with your changes.
222+
223+ # ## Phase 5: Test and Refine
224+
225+ 1. Set `use-jira-sandbox : true` and `is-draft-release: true`
226+ 2. Create a test version in the Jira sandbox for your project, and perhaps some dummy tickets associated with the version.
227+ 3. Open the `Automate release` workflow in the GitHub UI for your project.
228+ 4. Select your PR branch in the `Use workflow from` dropdown.
229+ 5. Fill in the rest of the form and submit.
230+ 6. Verify outputs : Check Jira sandbox for tickets, check the draft GitHub release, PRs for SQS/SQC/version-bump etc.
231+ 7. Iterate until you are satisfied.
232+ 8. Once ready, merge any changes you made to the reusable workflow in this repository.
233+ 9. Update the `AutomateRelease.yml` to use the released version of your reusable workflow.
234+ 10. Set `use-jira-sandbox : false` and `is-draft-release: false`
235+ 11. Merge the `AutomateRelease.yml` changes to your main branch.
218236
219237# # Resources
220238
0 commit comments