Skip to content

Commit b8ac9ac

Browse files
dreamorosiclaudesvozza
authored
ci(maintenance): Remove release comment automation (#5193)
Co-authored-by: Claude <[email protected]> Co-authored-by: Stefano Vozza <[email protected]>
1 parent 3f1b31e commit b8ac9ac

3 files changed

Lines changed: 13 additions & 98 deletions

File tree

.github/scripts/constants.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/scripts/post_release.js

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const { LABEL_PENDING_RELEASE, LABEL_RELEASED } = require('./constants');
1+
const LABEL_PENDING_RELEASE = 'pending-release';
2+
const LABEL_RELEASED = 'completed';
23

34
/**
45
* Fetch issues using GitHub REST API
@@ -37,26 +38,17 @@ const fetchIssues = async ({
3738
};
3839

3940
/**
40-
* Notify new release and close staged GitHub issue
41+
* Update labels on closed issues that are pending release
42+
*
43+
* Swaps the 'pending-release' label to 'completed' on each closed issue.
44+
* GitHub natively links releases to issues, so no comment is needed.
4145
*
4246
* @param {object} gh_client - Pre-authenticated REST client (Octokit)
4347
* @param {string} owner - GitHub Organization
4448
* @param {string} repository - GitHub repository
45-
* @param {string} release_version - GitHub Release version
4649
* @see {@link https://octokit.github.io/rest.js/v18#usage|Octokit client}
4750
*/
48-
const notifyRelease = async ({
49-
gh_client,
50-
core,
51-
owner,
52-
repository,
53-
release_version,
54-
}) => {
55-
const release_url = `https://github.com/${owner}/${repository}/releases/tag/v${release_version.replace(
56-
/v/g,
57-
''
58-
)}`;
59-
51+
const updateLabels = async ({ gh_client, core, owner, repository }) => {
6052
const issues = await fetchIssues({
6153
gh_client: gh_client,
6254
org: owner,
@@ -65,22 +57,7 @@ const notifyRelease = async ({
6557
});
6658

6759
issues.forEach(async (issue) => {
68-
core.info(`Updating issue number ${issue.number}`);
69-
70-
const comment = `This is now released under [${release_version}](${release_url}) version!`;
71-
try {
72-
await gh_client.rest.issues.createComment({
73-
owner: owner,
74-
repo: repository,
75-
body: comment,
76-
issue_number: issue.number,
77-
});
78-
} catch (error) {
79-
core.setFailed(error);
80-
throw new Error(
81-
`Failed to update issue ${issue.number} about ${release_version} release`
82-
);
83-
}
60+
core.info(`Updating labels for issue number ${issue.number}`);
8461

8562
// Remove staged label; keep existing ones
8663
const labels = issue.labels
@@ -106,14 +83,12 @@ const notifyRelease = async ({
10683

10784
// context: https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts
10885
module.exports = async ({ github, context, core }) => {
109-
const { RELEASE_VERSION } = process.env;
110-
core.info(`Running post-release script for ${RELEASE_VERSION} version`);
86+
core.info('Running post-release label update');
11187

112-
await notifyRelease({
88+
await updateLabels({
11389
gh_client: github,
11490
core,
11591
owner: context.repo.owner,
11692
repository: context.repo.repo,
117-
release_version: RELEASE_VERSION,
11893
});
11994
};

.github/workflows/post-release.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ name: Post Release
22

33
on:
44
# Triggered manually
5-
workflow_dispatch:
6-
inputs:
7-
versionNumber:
8-
required: true
9-
type: string
10-
description: "If running this manually please insert a version number that corresponds to the latest published in the GitHub releases (i.e. v1.1.1)"
5+
workflow_dispatch: {}
116
# Or triggered as result of a release
127
release:
138
types: [released]
@@ -20,26 +15,13 @@ jobs:
2015
permissions:
2116
contents: read
2217
issues: write
23-
discussions: write
24-
pull-requests: write
2518
runs-on: ubuntu-latest
26-
env:
27-
RELEASE_VERSION: ${{ inputs.versionNumber }}
2819
steps:
2920
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30-
- name: Get release version
31-
run: |
32-
# The code below does the following:
33-
# 1. If the workflow was triggered manually, it will use the version number provided by the user
34-
# 2. If the workflow was triggered by a release, it will use the version number of the release
35-
if [ -z "$RELEASE_VERSION" ]; then
36-
export RELEASE_VERSION=$(git describe --tags --abbrev=0)
37-
fi
38-
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
39-
- name: Update issues related to release
21+
- name: Update labels on issues related to release
4022
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
4123
with:
4224
github-token: ${{ secrets.GITHUB_TOKEN }}
4325
script: |
4426
const post_release = require('.github/scripts/post_release.js')
45-
await post_release({github, context, core})
27+
await post_release({github, context, core})

0 commit comments

Comments
 (0)