mirror of
https://github.com/tauri-apps/tauri-action.git
synced 2026-01-31 00:35:20 +01:00
feat(action) add iconPath input
This commit is contained in:
1
.github/workflows/test-action.yml
vendored
1
.github/workflows/test-action.yml
vendored
@@ -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."
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
BIN
example/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
18
src/main.ts
18
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<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) {
|
||||
|
||||
Reference in New Issue
Block a user