|
11 | 11 | release_tag: |
12 | 12 | description: 'Release tag to test (e.g., 1.2.3)' |
13 | 13 | required: true |
| 14 | + release_description: |
| 15 | + description: 'Release description for Update Center (e.g., "Support new feature")' |
| 16 | + required: true |
14 | 17 | prerelease: |
15 | 18 | description: 'Mark as prerelease (publishes to npm "next" tag instead of "latest")' |
16 | 19 | type: boolean |
|
19 | 22 | description: 'Skip updating "latest" tag (use for older version patches)' |
20 | 23 | type: boolean |
21 | 24 | default: false |
| 25 | + slack_channel: |
| 26 | + description: 'Slack channel for release notification' |
| 27 | + type: string |
| 28 | + default: 'ask-squad-web' |
22 | 29 |
|
23 | 30 | jobs: |
24 | 31 | publish: |
|
33 | 40 | ARTIFACTORY_REPOSITORY_NAME: 'sonarsource-npm-public-releases' |
34 | 41 | DRY_RUN: ${{ inputs.dry_run || false }} |
35 | 42 | steps: |
| 43 | + - name: Validate release description |
| 44 | + id: description |
| 45 | + env: |
| 46 | + RELEASE_BODY: ${{ github.event.release.body }} |
| 47 | + INPUT_DESCRIPTION: ${{ inputs.release_description }} |
| 48 | + run: | |
| 49 | + # Use input description for manual trigger, otherwise extract from release body |
| 50 | + if [ -n "$INPUT_DESCRIPTION" ]; then |
| 51 | + DESCRIPTION="$INPUT_DESCRIPTION" |
| 52 | + else |
| 53 | + # Extract description from release body (line starting with "Description:") |
| 54 | + DESCRIPTION=$(echo "$RELEASE_BODY" | grep -i "^Description:" | sed 's/^[Dd]escription:[[:space:]]*//') |
| 55 | + fi |
| 56 | +
|
| 57 | + if [ -z "$DESCRIPTION" ]; then |
| 58 | + echo "::error::Release body must contain a 'Description:' line for the Update Center entry." |
| 59 | + echo "::error::Example format:" |
| 60 | + echo "::error:: Description: Support new authentication method" |
| 61 | + echo "::error::" |
| 62 | + echo "::error:: ## What's Changed" |
| 63 | + echo "::error:: * PR details..." |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +
|
| 67 | + echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT |
| 68 | + echo "Extracted description: $DESCRIPTION" |
| 69 | +
|
36 | 70 | - name: Fetch the secrets |
37 | 71 | if: ${{ !inputs.dry_run }} |
38 | 72 | id: secrets |
@@ -113,3 +147,96 @@ jobs: |
113 | 147 | # Publish as sonarqube-scanner (legacy alias for backwards compatibility) |
114 | 148 | echo $(jq '.name = "sonarqube-scanner"' package.json) > package.json |
115 | 149 | npm publish --tag=${{ steps.npm-tag.outputs.tag }} --access=public |
| 150 | +
|
| 151 | + outputs: |
| 152 | + description: ${{ steps.description.outputs.description }} |
| 153 | + |
| 154 | + update-center: |
| 155 | + needs: publish |
| 156 | + permissions: |
| 157 | + contents: read |
| 158 | + id-token: write |
| 159 | + runs-on: ubuntu-latest |
| 160 | + env: |
| 161 | + RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag }} |
| 162 | + steps: |
| 163 | + - name: Fetch GitHub token |
| 164 | + id: secrets |
| 165 | + uses: SonarSource/vault-action-wrapper@v3 |
| 166 | + with: |
| 167 | + secrets: development/github/token/SonarSource-sonar-scanner-npm-release-automation token | github_token; |
| 168 | + |
| 169 | + - name: Checkout sonar-update-center-properties |
| 170 | + uses: actions/checkout@v6 |
| 171 | + with: |
| 172 | + repository: SonarSource/sonar-update-center-properties |
| 173 | + token: ${{ fromJSON(steps.secrets.outputs.vault).github_token }} |
| 174 | + path: update-center |
| 175 | + |
| 176 | + - name: Checkout sonar-scanner-npm (for scripts) |
| 177 | + uses: actions/checkout@v6 |
| 178 | + with: |
| 179 | + path: sonar-scanner-npm |
| 180 | + |
| 181 | + - name: Update scannernpm.properties |
| 182 | + working-directory: update-center |
| 183 | + run: | |
| 184 | + bash ../sonar-scanner-npm/scripts/update-update-center.sh \ |
| 185 | + scannernpm.properties \ |
| 186 | + "${RELEASE_TAG}" \ |
| 187 | + "${{ needs.publish.outputs.description }}" |
| 188 | +
|
| 189 | + - name: Create Pull Request |
| 190 | + id: create-pr |
| 191 | + working-directory: update-center |
| 192 | + env: |
| 193 | + GH_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).github_token }} |
| 194 | + run: | |
| 195 | + BRANCH="scannernpm-${RELEASE_TAG}" |
| 196 | + git config user.name "github-actions[bot]" |
| 197 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 198 | + git checkout -b "$BRANCH" |
| 199 | + git add scannernpm.properties |
| 200 | + git commit -m "Update SonarScanner for NPM to ${RELEASE_TAG}" |
| 201 | + git push origin "$BRANCH" |
| 202 | + PR_URL=$(gh pr create \ |
| 203 | + --title "Update SonarScanner for NPM to ${RELEASE_TAG}" \ |
| 204 | + --body "Automated PR to update SonarScanner for NPM to version ${RELEASE_TAG}. |
| 205 | +
|
| 206 | + Created by [sonar-scanner-npm release workflow](https://github.com/SonarSource/sonar-scanner-npm/actions/runs/${{ github.run_id }})." \ |
| 207 | + --base master) |
| 208 | + echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT |
| 209 | +
|
| 210 | + outputs: |
| 211 | + pr_url: ${{ steps.create-pr.outputs.pr_url }} |
| 212 | + |
| 213 | + notify: |
| 214 | + needs: [publish, update-center] |
| 215 | + permissions: |
| 216 | + id-token: write |
| 217 | + runs-on: ubuntu-latest |
| 218 | + env: |
| 219 | + RELEASE_TAG: ${{ github.event.release.tag_name || inputs.release_tag }} |
| 220 | + steps: |
| 221 | + - name: Fetch Slack token |
| 222 | + id: secrets |
| 223 | + uses: SonarSource/vault-action-wrapper@v3 |
| 224 | + with: |
| 225 | + secrets: development/kv/data/slack token | slack_token; |
| 226 | + |
| 227 | + - name: Send Slack notification |
| 228 | + uses: slackapi/slack-github-action@v2.1.0 |
| 229 | + with: |
| 230 | + method: chat.postMessage |
| 231 | + token: ${{ fromJSON(steps.secrets.outputs.vault).slack_token }} |
| 232 | + errors: true |
| 233 | + payload: | |
| 234 | + { |
| 235 | + "channel": "${{ inputs.slack_channel || 'ask-squad-web' }}", |
| 236 | + "attachments": [ |
| 237 | + { |
| 238 | + "color": "#36a64f", |
| 239 | + "text": ":package: *SonarScanner for NPM ${{ env.RELEASE_TAG }}* has been released!\n\n<https://github.com/SonarSource/sonar-scanner-npm/releases/tag/${{ env.RELEASE_TAG }}|View Release> | <https://www.npmjs.com/package/@sonar/scan/v/${{ env.RELEASE_TAG }}|npm package>\n\n:clipboard: *Next steps to complete the release:*\n1. Merge the Update Center PR: <${{ needs.update-center.outputs.pr_url }}|sonar-update-center-properties PR>\n2. Run the <https://github.com/SonarSource/sonar-update-center-properties/actions/workflows/deploy.yml|Deploy workflow> to publish the Update Center JSON\n3. Run the <https://github.com/SonarSource/sonarqube-documentation/actions/workflows/generate-release-notes.yml|Generate Release Notes workflow> and merge the resulting PR" |
| 240 | + } |
| 241 | + ] |
| 242 | + } |
0 commit comments