|
| 1 | +name: Release Notifications |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_run: |
| 7 | + workflows: ["Build, test, and publish to Maven Central"] |
| 8 | + types: [completed] |
| 9 | + |
| 10 | +jobs: |
| 11 | + notify-release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: github.event_name == 'release' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') |
| 14 | + steps: |
| 15 | + - name: Get release information |
| 16 | + id: release_info |
| 17 | + run: | |
| 18 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 19 | + TAG_NAME="${{ github.event.release.tag_name }}" |
| 20 | + # Remove 'v' prefix if present (Release Please for Java may or may not use it) |
| 21 | + VERSION=${TAG_NAME#v} |
| 22 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 23 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 24 | + echo "release_url=${{ github.event.release.html_url }}" >> $GITHUB_OUTPUT |
| 25 | + else |
| 26 | + # Extract from workflow run context |
| 27 | + echo "tag_name=latest" >> $GITHUB_OUTPUT |
| 28 | + echo "version=latest" >> $GITHUB_OUTPUT |
| 29 | + echo "release_url=https://github.com/${{ github.repository }}/releases/latest" >> $GITHUB_OUTPUT |
| 30 | + fi |
| 31 | +
|
| 32 | + - name: Create release announcement |
| 33 | + id: announcement |
| 34 | + run: | |
| 35 | + VERSION="${{ steps.release_info.outputs.version }}" |
| 36 | + TAG_NAME="${{ steps.release_info.outputs.tag_name }}" |
| 37 | + RELEASE_URL="${{ steps.release_info.outputs.release_url }}" |
| 38 | + |
| 39 | + if [ -z "$VERSION" ]; then |
| 40 | + VERSION="$TAG_NAME" |
| 41 | + fi |
| 42 | + |
| 43 | + cat > announcement.md << EOF |
| 44 | + 🚀 **Data Cloud JDBC Driver v$VERSION Released!** |
| 45 | + |
| 46 | + A new version of the Data Cloud JDBC Driver has been published to Maven Central. |
| 47 | + |
| 48 | + **What's New:** |
| 49 | + - Check the [release notes]($RELEASE_URL) for detailed changes |
| 50 | + - All changes follow semantic versioning principles |
| 51 | + |
| 52 | + **Installation:** |
| 53 | + \`\`\`xml |
| 54 | + <dependency> |
| 55 | + <groupId>com.salesforce.datacloud</groupId> |
| 56 | + <artifactId>jdbc</artifactId> |
| 57 | + <version>$VERSION</version> |
| 58 | + </dependency> |
| 59 | + \`\`\` |
| 60 | + |
| 61 | + **Resources:** |
| 62 | + - 📖 [Documentation](https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/data-cloud-jdbc.html) |
| 63 | + - 🐛 [Report Issues](https://github.com/forcedotcom/datacloud-jdbc/issues) |
| 64 | + - 💬 [Discussions](https://github.com/forcedotcom/datacloud-jdbc/discussions) |
| 65 | + |
| 66 | + --- |
| 67 | + *This release was automatically generated and published by our CI/CD pipeline.* |
| 68 | + EOF |
| 69 | + |
| 70 | + echo "announcement<<EOF" >> $GITHUB_OUTPUT |
| 71 | + cat announcement.md >> $GITHUB_OUTPUT |
| 72 | + echo "EOF" >> $GITHUB_OUTPUT |
| 73 | +
|
| 74 | + - name: Post release announcement |
| 75 | + uses: actions/github-script@v7 |
| 76 | + with: |
| 77 | + script: | |
| 78 | + const announcement = `${{ steps.announcement.outputs.announcement }}`; |
| 79 | + const tagName = '${{ steps.release_info.outputs.tag_name }}'; |
| 80 | + |
| 81 | + try { |
| 82 | + // Get the release to find the commit SHA |
| 83 | + const { data: releases } = await github.rest.repos.listReleases({ |
| 84 | + owner: context.repo.owner, |
| 85 | + repo: context.repo.repo |
| 86 | + }); |
| 87 | + |
| 88 | + const release = releases.find(r => r.tag_name === tagName); |
| 89 | + if (release && release.target_commitish) { |
| 90 | + await github.rest.repos.createCommitComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + commit_sha: release.target_commitish, |
| 94 | + body: announcement |
| 95 | + }); |
| 96 | + |
| 97 | + console.log('Posted release announcement as commit comment'); |
| 98 | + } else { |
| 99 | + console.log('Could not find release or commit SHA'); |
| 100 | + } |
| 101 | + } catch (error) { |
| 102 | + console.log('Could not post commit comment:', error.message); |
| 103 | + } |
| 104 | +
|
| 105 | + notify-failure: |
| 106 | + runs-on: ubuntu-latest |
| 107 | + if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' |
| 108 | + steps: |
| 109 | + - name: Notify release failure |
| 110 | + uses: actions/github-script@v7 |
| 111 | + with: |
| 112 | + script: | |
| 113 | + const workflowRun = context.payload.workflow_run; |
| 114 | + const issueBody = `## 🚨 Release Failed |
| 115 | + |
| 116 | + The automated release process has failed for commit \`${workflowRun.head_sha}\`. |
| 117 | + |
| 118 | + **Workflow Details:** |
| 119 | + - Workflow: ${workflowRun.name} |
| 120 | + - Run ID: ${workflowRun.id} |
| 121 | + - Commit: ${workflowRun.head_sha} |
| 122 | + - Branch: ${workflowRun.head_branch} |
| 123 | + - [View Logs](${workflowRun.html_url}) |
| 124 | + |
| 125 | + **Next Steps:** |
| 126 | + 1. Review the workflow logs to identify the issue |
| 127 | + 2. Fix the problem and retry the release |
| 128 | + 3. Close this issue once resolved |
| 129 | + |
| 130 | + --- |
| 131 | + *This issue was automatically created by the release notification workflow.*`; |
| 132 | + |
| 133 | + await github.rest.issues.create({ |
| 134 | + owner: context.repo.owner, |
| 135 | + repo: context.repo.repo, |
| 136 | + title: `Release failed for commit ${workflowRun.head_sha.substring(0, 7)}`, |
| 137 | + body: issueBody, |
| 138 | + labels: ['bug', 'release', 'ci'] |
| 139 | + }); |
| 140 | + |
| 141 | + console.log('Created failure notification issue'); |
0 commit comments