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 0000000..1f44bd7 Binary files /dev/null and b/example/icon.png differ diff --git a/src/main.ts b/src/main.ts index e26b30c..a134c38 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,7 +48,13 @@ interface Application { version: string } -async function buildProject(root: string, debug: boolean, { configPath, distPath }: { configPath: string | null, distPath: string | null }): Promise { +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) {