Skip to content

Commit 9afefbb

Browse files
authored
Merge pull request #121 from git-for-windows/release-git-convenience
release-git(announcement): add a helpful comment
2 parents 682d456 + c99c7f2 commit 9afefbb

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/release-git.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,60 @@ jobs:
109109
with:
110110
name: bundle-artifacts
111111
path: bundle-artifacts
112+
- name: Publish announcement mail as a stand-alone artifact
113+
id: announcement
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: announcement
117+
path: bundle-artifacts/announce-*
118+
- uses: actions/create-github-app-token@v1
119+
id: app-token
120+
with:
121+
app-id: ${{ secrets.GH_APP_ID }}
122+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
123+
owner: ${{ env.OWNER }}
124+
repositories: |
125+
${{ env.REPO }}
126+
- name: Add a comment about the announcement email to the Pull Request
127+
uses: actions/github-script@v7
128+
with:
129+
github-token: ${{ steps.app-token.outputs.token }}
130+
script: |
131+
const gitSHA = ${{ toJson(steps.bundle-artifacts.outputs.git-rev) }}
132+
const tagName = ${{ toJson(steps.bundle-artifacts.outputs.tag-name) }}
133+
const ver = ${{ toJson(steps.bundle-artifacts.outputs.ver) }}
134+
const announcementURL = ${{ toJson(steps.announcement.outputs.announcement) }}
135+
136+
const nth = (n) => {
137+
const suffix = ((n + 89) % 100) > 2 && ['th', 'st', 'nd', 'rd'][n % 10] || 'th'
138+
return `${n}${suffix}`
139+
}
140+
141+
const releaseURL = `https://github.com/${process.env.OWNER}/${process.env.REPO}/releases/tag/${tagName}`
142+
const [, baseVersion, rc ] = ver.match(/^(.*)-rc(\d+)$/) || [ver]
143+
const skeet =
144+
rc
145+
? `The ${nth(Number.parseInt(rc) + 1)} release candidate of Git for Windows ${baseVersion} is available, please test! ${releaseURL}`
146+
: `Git for Windows ${baseVersion} is available! ${releaseURL}`
147+
const blueskyLink = `https://bsky.app/intent/compose?text=${encodeURIComponent(skeet)}`
148+
149+
const body = `please [Share on Bluesky](${blueskyLink}) and send [the announcement email](${announcementURL}).`
150+
151+
const q = `repo:${process.env.OWNER}/${process.env.REPO}+is:pr+is:open+${gitSHA}`
152+
const { data } = await github.rest.search.issuesAndPullRequests({ q })
153+
if (data.items.length === 1) {
154+
const author = data.items[0].user.login
155+
const req = {
156+
owner: process.env.OWNER,
157+
repo: process.env.REPO,
158+
issue_number: data.items[0].number,
159+
body: `@${author}, ${body}`,
160+
}
161+
162+
await github.rest.issues.createComment(req)
163+
} else {
164+
core.warning(`${data.items.length} PRs found for ${gitSHA}, not posting a comment, would have posted\n${body}`)
165+
}
112166
github-release:
113167
needs: ['setup']
114168
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)