feat(action) add iconPath input

This commit is contained in:
Lucas Nogueira
2020-07-09 00:19:19 -03:00
parent 35b844226e
commit 583ab8c636
5 changed files with 19 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: ./example
iconPath: ./icon.png
tagName: example-v__VERSION__
releaseName: "Release example app v__VERSION__"
releaseBody: "See the assets to download this version and install."

View File

@@ -70,6 +70,7 @@ jobs:
| `releaseDraft` | false | Whether the release to create is a draft or not | bool | false |
| `prerelease` | false | Whether the release to create is a prerelease or not | bool | false |
| `releaseCommitish` | false | Any branch or commit SHA the Git tag is created from, unused if the Git tag already exists | string | SHA of current commit |
| `iconPath` | false | path to the PNG icon to use as app icon, relative to the projectPath | string | |
## Outputs

View File

@@ -24,6 +24,8 @@ inputs:
default: 'tauri.conf.json'
distPath:
description: 'path to the distributable folder with your index.html and JS/CSS'
iconPath:
description: 'path to the PNG icon to use as app icon, relative to the projectPath'
outputs:
releaseId:
description: 'The ID of the created release'

BIN
example/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -48,7 +48,13 @@ interface Application {
version: string
}
async function buildProject(root: string, debug: boolean, { configPath, distPath }: { configPath: string | null, distPath: string | null }): Promise<string[]> {
interface BuildOptions {
configPath: string | null
distPath: string | null
iconPath: string | null
}
async function buildProject(root: string, debug: boolean, { configPath, distPath, iconPath }: BuildOptions): Promise<string[]> {
return new Promise<string>((resolve) => {
if (hasTauriDependency(root)) {
const runner = usesYarn(root) ? 'yarn tauri' : 'npx tauri'
@@ -76,11 +82,16 @@ async function buildProject(root: string, debug: boolean, { configPath, distPath
cargoManifest.package.version = version
writeFileSync(manifestPath, toml.stringify(cargoManifest as any))
return {
const app = {
runner,
name: appName,
version
}
if (iconPath) {
return execCommand(`${runner} icon --icon ${join(root, iconPath)}`, { cwd: root }).then(() => app)
}
return app
})
}
})
@@ -126,6 +137,7 @@ async function run(): Promise<void> {
const projectPath = resolve(process.cwd(), core.getInput('projectPath') || process.argv[2])
const configPath = join(projectPath, core.getInput('configPath') || 'tauri.conf.json')
const distPath = core.getInput('distPath')
const iconPath = core.getInput('iconPath')
let tagName = core.getInput('tagName').replace('refs/tags/', '');
let releaseName = core.getInput('releaseName').replace('refs/tags/', '');
@@ -138,7 +150,7 @@ async function run(): Promise<void> {
throw new Error('`tag` is required along with `releaseName` when creating a release.')
}
const artifacts = await buildProject(projectPath, false, { configPath: existsSync(configPath) ? configPath : null, distPath })
const artifacts = await buildProject(projectPath, false, { configPath: existsSync(configPath) ? configPath : null, distPath, iconPath })
let uploadUrl: string
if (tagName) {