@@ -40,7 +40,7 @@ const encode = (str: string): string =>
4040
4141async function run ( ) : Promise < void > {
4242 try {
43- const tagName = core . getInput ( 'tag_name' , { required : true } )
43+ const tagName = getReleaseTagName ( )
4444 const indent = parseInt ( core . getInput ( 'indent' ) || DEFAULT_INDENT )
4545 const allReleases = await octokit . rest . repos . listReleases ( {
4646 owner : github . context . repo . owner ,
@@ -68,7 +68,11 @@ async function run(): Promise<void> {
6868 addURLAndSha : renderTemplate ( releaseMap , indent )
6969 }
7070
71- const templ = fs . readFileSync ( '.spin-plugin.json.tmpl' , 'utf8' )
71+ const templateFile =
72+ core . getInput ( 'template_file' , { trimWhitespace : true } ) ||
73+ '.spin-plugin.json.tmpl'
74+
75+ const templ = fs . readFileSync ( templateFile , 'utf8' )
7276 const rendered = mustache . render ( templ , view )
7377 const renderedBase64 = encode ( rendered )
7478
@@ -82,7 +86,7 @@ async function run(): Promise<void> {
8286 processedTemplate : renderedBase64
8387 }
8488
85- const httpclient = new httpm . HttpClient ( 'spin-plugins-release-bot ' )
89+ const httpclient = new httpm . HttpClient ( 'spin-plugins-releaser ' )
8690
8791 core . debug ( JSON . stringify ( releaseReq , null , '\t' ) )
8892
@@ -123,4 +127,16 @@ function renderTemplate(
123127 }
124128}
125129
130+ function getReleaseTagName ( ) : string {
131+ if ( github . context . ref . startsWith ( 'refs/tags/v' ) ) {
132+ return github . context . ref . replace ( 'refs/tags/v' , '' )
133+ }
134+
135+ if ( github . context . ref === 'refs/heads/main' ) {
136+ return 'canary'
137+ }
138+
139+ throw new Error ( `invalid ref '${ github . context . ref } ' found` )
140+ }
141+
126142run ( )
0 commit comments