Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
imyanice committed May 2, 2024
1 parent 78ecaec commit bc18494
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ jobs:
uses: ./
with:
targets: 'x86_64-apple-darwin,aarch64-apple-darwin'
srcDir: "./test-dir/"
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ branding:
# Define your inputs here.
inputs:
targets:
description: 'List of targets the action should create an executable'
description: 'List of targets the action should create an executable for'
required: true
default: ''
srcDir:
description: 'The folder containing the "target" directory. AKA your source folder.'
required: false
default: "./"
runs:
using: node20
main: dist/index.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"execa": "^8.0.1"
"execa": "^8.0.1",
"toml": "^3.0.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
83 changes: 80 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,91 @@ import { execa } from 'execa'
import fs from 'node:fs'
import * as core from '@actions/core'
import { getInput } from '@actions/core'
import * as toml from 'toml'

interface BuildOptions {
identifier: string,
category:
'public.app-category.business' |
'public.app-category.developer-tools' |
'public.app-category.education' |
'public.app-category.entertainment' |
'public.app-category.finance' |
'public.app-category.games' |
'public.app-category.action-games' |
'public.app-category.adventure-games' |
'public.app-category.arcade-games' |
'public.app-category.board-games' |
'public.app-category.card-games' |
'public.app-category.casino-games' |
'public.app-category.dice-games' |
'public.app-category.educational-games' |
'public.app-category.family-games' |
'public.app-category.kids-games' |
'public.app-category.music-games' |
'public.app-category.puzzle-games' |
'public.app-category.racing-games' |
'public.app-category.role-playing-games' |
'public.app-category.simulation-games' |
'public.app-category.sports-games' |
'public.app-category.strategy-games' |
'public.app-category.trivia-games' |
'public.app-category.word-games' |
'public.app-category.graphics-design' |
'public.app-category.healthcare-fitness' |
'public.app-category.lifestyle' |
'public.app-category.medical' |
'public.app-category.music' |
'public.app-category.news' |
'public.app-category.photography' |
'public.app-category.productivity' |
'public.app-category.reference' |
'public.app-category.social-networking' |
'public.app-category.sports' |
'public.app-category.travel' |
'public.app-category.utilities' |
'public.app-category.video' |
'public.app-category.weather',
copyright: string,
icon: string[],
displayName: string
}

class BuildOptions {
constructor(parseElement: any) {
this.category = parseElement.category
this.icon = parseElement.icon
this.identifier = parseElement.identifier
this.copyright = parseElement.copyright
this.displayName = parseElement.displayName
}

}

try {
execa('echo', ['args'], { stdio: 'inherit' })
let targets = getInput('targets').split(',')
targets.forEach(target => {
console.log(target)
let tomlData: string
let srcDir = (getInput('srcDir').startsWith('./') ? getInput('srcDir') : './' + getInput('srcDir')) + (getInput('srcDir').endsWith('/') ? '' : '/')
fs.readFile(srcDir + 'Cargo.toml', 'utf-8', (err, data) => {
if (err) core.setFailed(err.message)
tomlData = data
let packageName = JSON.parse(JSON.stringify(toml.parse(tomlData))).package.name
if (packageName == undefined) core.setFailed('Could not find your package name in your Cargo.toml.')
let buildOptions = new BuildOptions(JSON.parse(JSON.stringify(toml.parse(tomlData)))['rust-build-macos'])
if (buildOptions == undefined) core.setFailed('Invalid toml data!')

targets.forEach(target => {
switch (target) {
case 'aarch64-apple-darwin': {
fs.copyFile(srcDir + 'target/aarch64-apple-darwin/debug/' + packageName, './bundles/aarch64-apple-darwin/' + buildOptions.displayName + '.app/Contents/MacOS/' + packageName, err1 => {
if (err1) core.setFailed(err1.message)
})
}
}
})
console.log(fs.readdirSync('./'))
})
console.log(fs.readdirSync('./'))
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
Expand Down
7 changes: 7 additions & 0 deletions test-dir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ serde = { version = "1.0.199", features = ["derive"] }

[build-dependencies]
slint-build = "1.5"

[rust-build-macos]
identifier = "me.yanice.pomodoro-timer"
category = "public.app-category.utilities"
copyright = "© 2024 Yanice (imyanice)."
icon = ["icons/icon.png"]
displayName = "Pomodoro Timer"
Binary file added test-dir/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bc18494

Please sign in to comment.