From 583ab8c6368da100465ef1193a25db66d2d75eaa Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Thu, 9 Jul 2020 00:19:19 -0300 Subject: [PATCH] feat(action) add iconPath input --- .github/workflows/test-action.yml | 1 + README.md | 1 + action.yml | 2 ++ example/icon.png | Bin 0 -> 3767 bytes src/main.ts | 18 +++++++++++++++--- 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 example/icon.png diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index caa5b5c..14de1a5 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -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." diff --git a/README.md b/README.md index 473baa8..bde5c50 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 213720c..3a84e98 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/example/icon.png b/example/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1f44bd7762a96d2871cc89741c37735db41f8390 GIT binary patch literal 3767 zcmeHJdpK148rIRy?t->zI8DZ5(?vB@Ta;@^HOi$6ikOxf8++U~#$}jM4JsS8<(8PE zk{FlC)FNX{XWY_+5OZs0gxtnZ7&2zeVeI}t|LnicSUHD{D>GJ`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;SC;z(2x z!~~>bhyQe}`Hjy57OPfpk6cg!{rR86**t+(XXtX`Adt#UL}`ZE2pe)!gBDAl#}E!E z$LuY@^zWJt?3nSLvTZ)YH$)Tt9l6mcV9_-cA*mb~<_Jz${dH=5CO0Dj`)Hd|5^15k zV`{xT#@aqO&S&4-_;swdH_1ZLowoEIa);mPx&JwOan6B5y zAuTZS4bz+Mv~g$IZNs;YpKpps*sasraZ%qpvaI#JL)-n zAQnz4(ya(7(_1$B0ZHT+xs>{%28WtA=DG { +interface BuildOptions { + configPath: string | null + distPath: string | null + iconPath: string | null +} + +async function buildProject(root: string, debug: boolean, { configPath, distPath, iconPath }: BuildOptions): Promise { return new Promise((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 { 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 { 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) {