@@ -6,18 +6,14 @@ const util = require('./util');
66
77const { Octokit } = require ( "@octokit/rest" ) ;
88const { graphql } = require ( "@octokit/graphql" ) ;
9- const fetch = require ( 'node-fetch' ) ;
109
1110const OWNER = 'microsoft' ;
1211const REPO = 'azure-pipelines-agent' ;
1312const GIT = 'git' ;
1413const VALID_RELEASE_RE = / ^ [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } $ / ;
1514const octokit = new Octokit ( { } ) ; // only read-only operations, no need to auth
1615
17- const graphqlWithFetch = graphql . defaults ( { // Create a reusable GraphQL instance with fetch
18- request : {
19- fetch,
20- } ,
16+ const graphqlWithAuth = graphql . defaults ( {
2117 headers : {
2218 authorization : process . env . PAT ? `token ${ process . env . PAT } ` : undefined ,
2319 }
@@ -63,9 +59,8 @@ async function verifyNewReleaseTagOk(newRelease) {
6359
6460function writeAgentVersionFile ( newRelease ) {
6561 console . log ( 'Writing agent version file' )
66- if ( ! opt . options . dryrun ) {
67- fs . writeFileSync ( path . join ( __dirname , '..' , 'src' , 'agentversion' ) , `${ newRelease } \n` ) ;
68- }
62+ // Always write the agent version file, even in dry-run mode
63+ fs . writeFileSync ( path . join ( __dirname , '..' , 'src' , 'agentversion' ) , `${ newRelease } \n` ) ;
6964 return newRelease ;
7065}
7166
@@ -102,7 +97,7 @@ async function fetchPRsForSHAsGraphQL(commitSHAs) {
10297 ` ;
10398
10499 try {
105- var response = await graphqlWithFetch ( fullQuery , {
100+ var response = await graphqlWithAuth ( fullQuery , {
106101 repo : REPO ,
107102 owner : OWNER ,
108103 } ) ;
@@ -293,17 +288,17 @@ function editReleaseNotesFile(body) {
293288}
294289
295290function commitAndPush ( directory , release , branch ) {
296- util . execInForeground ( GIT + " checkout -b " + branch , directory , opt . options . dryrun ) ;
297- util . execInForeground ( `${ GIT } commit -m "Agent Release ${ release } " ` , directory , opt . options . dryrun ) ;
298- util . execInForeground ( `${ GIT } -c credential.helper='!f() { echo "username=pat"; echo "password=$PAT"; };f' push --set-upstream origin ${ branch } ` , directory , opt . options . dryrun ) ;
291+ util . execInForeground ( GIT + " checkout -b " + branch , directory , false ) ; // Always execute checkout
292+ util . execInForeground ( `${ GIT } commit -m "Agent Release ${ release } " ` , directory , false ) ; // Always execute commit
293+ util . execInForeground ( `${ GIT } -c credential.helper='!f() { echo "username=pat"; echo "password=$PAT"; };f' push --set-upstream origin ${ branch } ` , directory , opt . options . dryrun ) ; // Only push respects dryrun
299294}
300295
301296function commitAgentChanges ( directory , release ) {
302297 var newBranch = `releases/${ release } ` ;
303- util . execInForeground ( `${ GIT } add ${ path . join ( 'src' , 'agentversion' ) } ` , directory , opt . options . dryrun ) ;
304- util . execInForeground ( `${ GIT } add releaseNote.md` , directory , opt . options . dryrun ) ;
305- util . execInForeground ( `${ GIT } config --global user.email "[email protected] "` , null , opt . options . dryrun ) ; 306- util . execInForeground ( `${ GIT } config --global user.name "azure-pipelines-bot"` , null , opt . options . dryrun ) ;
298+ util . execInForeground ( `${ GIT } add ${ path . join ( 'src' , 'agentversion' ) } ` , directory , false ) ; // Always execute add
299+ util . execInForeground ( `${ GIT } add releaseNote.md` , directory , false ) ; // Always execute add
300+ util . execInForeground ( `${ GIT } config --global user.email "[email protected] "` , null , false ) ; // Always execute config 301+ util . execInForeground ( `${ GIT } config --global user.name "azure-pipelines-bot"` , null , false ) ; // Always execute config
307302 commitAndPush ( directory , release , newBranch ) ;
308303}
309304
0 commit comments