Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #3

Merged
merged 13 commits into from
Jan 12, 2024
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ jobs:

- name: Build
run: |
nimble install -d -y
nimble buildapp

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: appimage-amd64
path: ./*-*-*.AppImage
path: ./*.AppImage
if-no-files-found: error

windows:
Expand All @@ -32,10 +33,12 @@ jobs:
- uses: iffy/[email protected]

- name: Build
run: nimble buildr
run: |
nimble install -d -y
nimble buildr
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: win-amd64
path: ./*-*-*.exe
path: ./*.exe
if-no-files-found: error
47 changes: 22 additions & 25 deletions ImExample.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ backend = "cpp"
# Dependencies

requires "nim >= 1.6.2"
requires "kdl >= 1.0.0"
requires "kdl >= 2.0.1"
requires "nimgl >= 1.3.2"
requires "stb_image >= 2.5"
requires "imstyle >= 1.0.0"
requires "openurl >= 2.0.3"
requires "imstyle >= 3.0.0"
requires "openurl >= 2.0.4"
requires "tinydialogs >= 1.0.0"
requires "constructor >= 1.2.0"

import std/[strformat, options]
import src/types
import kdl
import src/configtype

const configPath {.strdefine.} = "config.kdl"
const config = parseKdlFile(configPath).decode(Config)
const config = Config()

version = config.version
namedBin["main"] = config.name
Expand All @@ -29,13 +28,12 @@ let arch = getEnv("ARCH", "amd64")
let outPath = getEnv("OUTPATH", toExe &"{config.name}-{version}-{arch}")
let flags = getEnv("FLAGS")

let args = &"--app:gui --out:{outPath} --cpu:{arch} -d:configPath={configPath} {flags}"
let args = &"--app:gui --out:{outPath} --cpu:{arch} {flags}"

task buildr, "Build the application for release":
exec "nimble install -d -y"
exec &"nim cpp -d:release {args} main.nim"
exec &"nimble c -d:release {args} main.nim"

const desktop = """
const desktopTemplate = """
[Desktop Entry]
Name=$name
Exec=AppRun
Expand All @@ -53,28 +51,27 @@ task buildapp, "Build the AppImage":
let appimagePath = &"{config.name}-{version}-{arch}.AppImage"

# Compile applicaiton executable
if not existsDir("AppDir"): mkDir("AppDir")
exec "nimble install -d -y"
exec &"nim cpp -d:release -d:appimage {args} --out:AppDir/AppRun main.nim"
if not dirExists("AppDir"): mkDir("AppDir")
exec &"nimble c -d:release -d:appimage {args} --out:AppDir/AppRun main.nim"

# Make desktop file
writeFile(
&"AppDir/{config.name}.desktop",
desktop % [
"name", config.name,
"categories", config.categories.join(";"),
"version", config.version,
"comment", config.comment,
&"AppDir/{config.name}.desktop",
desktopTemplate % [
"name", config.name,
"categories", config.categories.join(";"),
"version", config.version,
"comment", config.comment,
"arch", arch
]
)
# Copy icons
cpFile(config.iconPath, "AppDir/.DirIcon")
cpFile(config.svgIconPath, &"AppDir/{config.name}.svg")

if config.appstreamPath.isSome:
if config.appstreamPath.len > 0:
mkDir("AppDir/usr/share/metainfo")
cpFile(config.appstreamPath.get, &"AppDir/usr/share/metainfo/{config.name}.appdata.xml")
cpFile(config.appstreamPath, &"AppDir/usr/share/metainfo/{config.name}.appdata.xml")

# Get appimagetool
var appimagetoolPath = "appimagetool"
Expand All @@ -83,15 +80,15 @@ task buildapp, "Build the AppImage":
exec(&"{appimagetoolPath} --help")
except OSError:
appimagetoolPath = "./appimagetool-x86_64.AppImage"
if not existsFile(appimagetoolPath):
if not fileExists(appimagetoolPath):
echo &"Downloading {appimagetoolPath}"
exec &"wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O ", appimagetoolPath
exec &"wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O {appimagetoolPath}"
exec &"chmod +x {appimagetoolPath}"

# Actually use appimagetool to build the AppImage
if config.ghRepo.isSome:
echo "Building updateable AppImage"
exec &"{appimagetoolPath} -u \"gh-releases-zsync|{config.ghRepo.get[0]}|{config.ghRepo.get[0]}|latest|{config.name}-*-{arch}.AppImage.zsync\" AppDir {appimagePath}"
exec &"{appimagetoolPath} -u \"gh-releases-zsync|{config.ghRepo.get.user}|{config.ghRepo.get.repo}|latest|{config.name}-*-{arch}.AppImage.zsync\" AppDir {appimagePath}"
else:
echo &"ghRepo not defined. Skipping updateable AppImage"
exec &"{appimagetoolPath} AppDir {appimagePath}"
Loading
Loading