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
10885module . 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} ;
0 commit comments