@@ -6,7 +6,7 @@ const tc = require('turbocolor');
66const execa = require ( 'execa' ) ;
77const Listr = require ( 'listr' ) ;
88const path = require ( 'path' ) ;
9- const octokit = require ( '@octokit/rest' ) ( )
9+ const { Octokit } = require ( '@octokit/rest' ) ;
1010const common = require ( './common' ) ;
1111const fs = require ( 'fs-extra' ) ;
1212
@@ -28,18 +28,18 @@ async function main() {
2828 // repo must be clean
2929 common . checkGit ( tasks ) ;
3030
31- const { tag , confirm } = await common . askTag ( ) ;
31+ const { npmTag , confirm } = await common . askNpmTag ( version ) ;
3232
3333 if ( ! confirm ) {
3434 return ;
3535 }
3636
3737 if ( ! dryRun ) {
3838 // publish each package in NPM
39- common . publishPackages ( tasks , common . packages , version , tag ) ;
39+ common . publishPackages ( tasks , common . packages , version , npmTag ) ;
4040
4141 // push tag to git remote
42- publishGit ( tasks , version , changelog ) ;
42+ publishGit ( tasks , version , changelog , npmTag ) ;
4343 }
4444
4545 const listr = new Listr ( tasks ) ;
@@ -48,10 +48,10 @@ async function main() {
4848 // Dry run doesn't publish to npm or git
4949 if ( dryRun ) {
5050 console . log ( `
51- \n${ tc . yellow ( 'Did not publish. Remove the "--dry-run" flag to publish:' ) } \n${ tc . green ( version ) } to ${ tc . cyan ( tag ) } \n
51+ \n${ tc . yellow ( 'Did not publish. Remove the "--dry-run" flag to publish:' ) } \n${ tc . green ( version ) } to ${ tc . cyan ( npmTag ) } \n
5252 ` ) ;
5353 } else {
54- console . log ( `\nionic ${ version } published to ${ tag } !! 🎉\n` ) ;
54+ console . log ( `\nionic ${ version } published to ${ npmTag } !! 🎉\n` ) ;
5555 }
5656
5757 } catch ( err ) {
@@ -70,13 +70,13 @@ function checkProductionRelease() {
7070 }
7171}
7272
73- function publishGit ( tasks , version , changelog ) {
74- const tag = `v${ version } ` ;
73+ function publishGit ( tasks , version , changelog , npmTag ) {
74+ const gitTag = `v${ version } ` ;
7575
7676 tasks . push (
7777 {
78- title : `Tag latest commit ${ tc . dim ( `(${ tag } )` ) } ` ,
79- task : ( ) => execa ( 'git' , [ 'tag' , `${ tag } ` ] , { cwd : common . rootDir } )
78+ title : `Tag latest commit ${ tc . dim ( `(${ gitTag } )` ) } ` ,
79+ task : ( ) => execa ( 'git' , [ 'tag' , `${ gitTag } ` ] , { cwd : common . rootDir } )
8080 } ,
8181 {
8282 title : 'Push branches to remote' ,
@@ -88,7 +88,7 @@ function publishGit(tasks, version, changelog) {
8888 } ,
8989 {
9090 title : 'Publish Github release' ,
91- task : ( ) => publishGithub ( version , tag , changelog )
91+ task : ( ) => publishGithub ( version , gitTag , changelog , npmTag )
9292 }
9393 ) ;
9494}
@@ -116,10 +116,12 @@ function findChangelog() {
116116 return lines . slice ( start , end ) . join ( '\n' ) . trim ( ) ;
117117}
118118
119- async function publishGithub ( version , tag , changelog ) {
120- octokit . authenticate ( {
121- type : 'oauth' ,
122- token : process . env . GH_TOKEN
119+ async function publishGithub ( version , gitTag , changelog , npmTag ) {
120+ // If the npm tag is next then publish as a prerelease
121+ const prerelease = npmTag === 'next' ? true : false ;
122+
123+ const octokit = new Octokit ( {
124+ auth : process . env . GH_TOKEN
123125 } ) ;
124126
125127 let branch = await execa . stdout ( 'git' , [ 'symbolic-ref' , '--short' , 'HEAD' ] ) ;
@@ -132,9 +134,10 @@ async function publishGithub(version, tag, changelog) {
132134 owner : 'ionic-team' ,
133135 repo : 'ionic' ,
134136 target_commitish : branch ,
135- tag_name : tag ,
137+ tag_name : gitTag ,
136138 name : version ,
137139 body : changelog ,
140+ prerelease : prerelease
138141 } ) ;
139142}
140143
0 commit comments