Skip to content

Commit a7083c3

Browse files
committed
more changes to releaser
Signed-off-by: Rajat Jindal <[email protected]>
1 parent ecc7e64 commit a7083c3

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: 'Spin plugin releaser'
22
description: 'Set up your GitHub Actions workflow with a specific version of spin'
33
author: 'Fermyon Engineering'
44
inputs:
5-
tag_name:
6-
required: true
7-
description: 'the release tag'
5+
template_file:
6+
required: false
7+
description: 'the plugin template file'
88
github_token:
99
required: false
1010
description: 'github token used for downloading artifacts to render template'

dist/index.js

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/release.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const encode = (str: string): string =>
4040

4141
async 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+
126142
run()

0 commit comments

Comments
 (0)