@ -26,15 +26,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result ;
return result ;
} ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . postMessageToSlack = exports . updateTag = exports . validateIfReleaseIsPublished = void 0 ;
exports . updateTag = exports . validateIfReleaseIsPublished = void 0 ;
const core = _ _importStar ( _ _nccwpck _require _ _ ( 2186 ) ) ;
const core = _ _importStar ( _ _nccwpck _require _ _ ( 2186 ) ) ;
const github _1 = _ _nccwpck _require _ _ ( 5438 ) ;
const github _1 = _ _nccwpck _require _ _ ( 5438 ) ;
const http _client _1 = _ _nccwpck _require _ _ ( 9925 ) ;
async function findTag ( tag , octokitClient ) {
async function findTag ( tag , octokitClient ) {
try {
try {
const { data : foundTag } = await octokitClient . git . getRef ( {
const { data : foundTag } = await octokitClient . git . getRef ( {
... github _1 . context . repo ,
... github _1 . context . repo ,
ref : ` tags/ ${ tag } `
ref : ` tags/ ${ tag } ` ,
} ) ;
} ) ;
return foundTag ;
return foundTag ;
}
}
@ -84,7 +83,7 @@ async function updateTag(sourceTag, targetTag, octokitClient) {
... github _1 . context . repo ,
... github _1 . context . repo ,
ref : refName ,
ref : refName ,
sha : sourceTagSHA ,
sha : sourceTagSHA ,
force : true
force : true ,
} ) ;
} ) ;
}
}
else {
else {
@ -92,17 +91,11 @@ async function updateTag(sourceTag, targetTag, octokitClient) {
await octokitClient . git . createRef ( {
await octokitClient . git . createRef ( {
... github _1 . context . repo ,
... github _1 . context . repo ,
ref : ` refs/ ${ refName } ` ,
ref : ` refs/ ${ refName } ` ,
sha : sourceTagSHA
sha : sourceTagSHA ,
} ) ;
} ) ;
}
}
}
}
exports . updateTag = updateTag ;
exports . updateTag = updateTag ;
async function postMessageToSlack ( slackWebhook , message ) {
const jsonData = { text : message } ;
const http = new http _client _1 . HttpClient ( ) ;
await http . postJson ( slackWebhook , jsonData ) ;
}
exports . postMessageToSlack = postMessageToSlack ;
/***/ } ) ,
/***/ } ) ,
@ -134,34 +127,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
const core = _ _importStar ( _ _nccwpck _require _ _ ( 2186 ) ) ;
const core = _ _importStar ( _ _nccwpck _require _ _ ( 2186 ) ) ;
const github = _ _importStar ( _ _nccwpck _require _ _ ( 5438 ) ) ;
const github = _ _importStar ( _ _nccwpck _require _ _ ( 5438 ) ) ;
const github _1 = _ _nccwpck _require _ _ ( 5438 ) ;
const api _utils _1 = _ _nccwpck _require _ _ ( 2430 ) ;
const api _utils _1 = _ _nccwpck _require _ _ ( 2430 ) ;
const version _utils _1 = _ _nccwpck _require _ _ ( 1534 ) ;
const version _utils _1 = _ _nccwpck _require _ _ ( 1534 ) ;
async function run ( ) {
async function run ( ) {
try {
try {
const token = core . getInput ( 'token' ) ;
const token = core . getInput ( "token" ) ;
const octokitClient = github . getOctokit ( token ) ;
const octokitClient = github . getOctokit ( token ) ;
const sourceTagName = core . getInput ( 'source-tag' ) ;
const sourceTagName = core . getInput ( "source-tag" ) ;
const rc = core . getInput ( "rc" ) ;
if ( rc !== "" ) {
await api _utils _1 . updateTag ( sourceTagName , "rc" , octokitClient ) ;
core . setOutput ( "major-tag" , "rc" ) ;
core . info ( ` 'rc' tag now points to the ' ${ sourceTagName } ' tag ` ) ;
}
else {
version _utils _1 . validateSemverVersionFromTag ( sourceTagName ) ;
version _utils _1 . validateSemverVersionFromTag ( sourceTagName ) ;
await api _utils _1 . validateIfReleaseIsPublished ( sourceTagName , octokitClient ) ;
await api _utils _1 . validateIfReleaseIsPublished ( sourceTagName , octokitClient ) ;
const majorTag = version _utils _1 . getMajorTagFromFullTag ( sourceTagName ) ;
const majorTag = version _utils _1 . getMajorTagFromFullTag ( sourceTagName ) ;
await api _utils _1 . updateTag ( sourceTagName , majorTag , octokitClient ) ;
await api _utils _1 . updateTag ( sourceTagName , majorTag , octokitClient ) ;
core . setOutput ( 'major-tag' , majorTag ) ;
core . setOutput ( "major-tag" , majorTag ) ;
core . info ( ` The ' ${ majorTag } ' major tag now points to the ' ${ sourceTagName } ' tag ` ) ;
core . info ( ` The ' ${ majorTag } ' major tag now points to the ' ${ sourceTagName } ' tag ` ) ;
const slackMessage = ` The ${ majorTag } tag has been successfully updated for the ${ github _1 . context . repo . repo } action to include changes from the ${ sourceTagName } ` ;
}
await reportStatusToSlack ( slackMessage ) ;
}
}
catch ( error ) {
catch ( error ) {
core . setFailed ( error . message ) ;
core . setFailed ( error . message ) ;
const slackMessage = ` Failed to update a major tag for the ${ github _1 . context . repo . repo } action ` ;
await reportStatusToSlack ( slackMessage ) ;
}
}
;
async function reportStatusToSlack ( message ) {
const slackWebhook = core . getInput ( 'slack-webhook' ) ;
if ( slackWebhook ) {
await api _utils _1 . postMessageToSlack ( slackWebhook , message ) ;
}
}
}
}
run ( ) ;
run ( ) ;