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