mirror of
https://github.com/veden/Rampant.git
synced 2024-12-24 20:14:35 +02:00
IT-111: switched from Racket for zip and copy scripts for cicd
This commit is contained in:
parent
1830611a00
commit
2d51af4033
111
action.fish
Executable file
111
action.fish
Executable file
@ -0,0 +1,111 @@
|
||||
#!/bin/fish
|
||||
|
||||
argparse --min-args=1 --max-args=1 'dir=?' 'serverDir=?' 'silent' 'auth=?' 'help' -- $argv
|
||||
or return 2
|
||||
|
||||
if test $_flag_help
|
||||
echo "commands are:
|
||||
copy: --dir, --serverDir
|
||||
zip: --dir, --serverDir, --silent
|
||||
upload: --dir, --auth
|
||||
options:
|
||||
--dir=<can set directory for output or file to upload>
|
||||
--serverDir=<can set secondary directory for output when testing multiplayer>
|
||||
--auth=<api key for uploading to mod portal>
|
||||
--help=<get commands and options printed>"
|
||||
return 0
|
||||
end
|
||||
|
||||
function getTitle
|
||||
set title (jq -r .title info.json)
|
||||
set ver (jq -r .version info.json)
|
||||
echo $title"_"$ver
|
||||
end
|
||||
|
||||
function copyFiles --argument-names copyFolder
|
||||
mkdir -p $copyFolder
|
||||
|
||||
cp --verbose ./*.lua $copyFolder
|
||||
cp --verbose ./*.png $copyFolder
|
||||
cp --verbose ./*.json $copyFolder
|
||||
cp --verbose -r ./sounds $copyFolder
|
||||
cp --verbose -r ./locale $copyFolder
|
||||
cp --verbose -r ./libs $copyFolder
|
||||
cp --verbose -r ./graphics $copyFolder
|
||||
cp --verbose -r ./prototypes $copyFolder
|
||||
cp --verbose -r ./migrations $copyFolder
|
||||
cp --verbose ./COPYING $copyFolder
|
||||
cp --verbose ./changelog.txt $copyFolder
|
||||
cp --verbose ./README.md $copyFolder
|
||||
end
|
||||
|
||||
set modFolder $_flag_dir
|
||||
if test -z "$modFolder"
|
||||
set modFolder "/mnt/gallery/gameFiles/factorio/mods"
|
||||
end
|
||||
|
||||
set title (getTitle)
|
||||
set modName "Rampant"
|
||||
|
||||
switch $argv[1]
|
||||
case copy
|
||||
echo "copying"
|
||||
copyFiles "$modFolder/$title"
|
||||
|
||||
if test -n "$_flag_serverDir"
|
||||
copyFiles $_flag_serverDir
|
||||
end
|
||||
case zip
|
||||
if test -z "$_flag_silent"
|
||||
echo "zipping"
|
||||
end
|
||||
set zipName "$modFolder/$title.zip"
|
||||
rm -f zipName
|
||||
ln -s (pwd) $title
|
||||
|
||||
set zipProgress (zip $zipName \
|
||||
$title/*.lua $title/*.png $title/*.json $title/sounds/**/* $title/locale/**/* \
|
||||
$title/libs/**/* $title/graphics/**/* $title/prototypes/**/* $title/migrations/**/* \
|
||||
$title/COPYING $title/changelog.txt $title/README.md)
|
||||
|
||||
if test -z "$_flag_silent"
|
||||
echo $zipProgress
|
||||
end
|
||||
|
||||
if test -n "$_flag_serverDir"
|
||||
cp $zipName $_flag_serverDir
|
||||
end
|
||||
|
||||
rm ./$title
|
||||
|
||||
echo $zipName
|
||||
|
||||
case upload
|
||||
echo "init uploading"
|
||||
|
||||
set initResponse (curl --no-progress-meter -X POST "https://mods.factorio.com/api/v2/mods/releases/init_upload" \
|
||||
-H "Authorization: Bearer $_flag_auth" -H "Content-Type: multipart/form-data" \
|
||||
-F mod=$modName)
|
||||
|
||||
if test (echo "$initResponse" | jq -r .error '-') != "null"
|
||||
echo "init upload failed: $initResponse"
|
||||
return 3
|
||||
end
|
||||
|
||||
echo "uploading"
|
||||
|
||||
set finishResponse (curl --no-progress-meter -X POST (echo "$initResponse" | jq -r .upload_url '-') \
|
||||
-H "Authorization: Bearer $_flag_auth" -H "Content-Type: multipart/form-data" \
|
||||
-F file="@$_flag_dir")
|
||||
|
||||
if test (echo "$finishResponse" | jq -r .error '-') != "null"
|
||||
echo "finish upload failed: $finishResponse"
|
||||
return 4
|
||||
else
|
||||
echo "upload success: $finishResponse"
|
||||
end
|
||||
|
||||
case '*'
|
||||
echo "commands are: copy, zip"
|
||||
return 1
|
||||
end
|
118
make.sh
118
make.sh
@ -1,118 +0,0 @@
|
||||
#! /usr/bin/env racket
|
||||
#lang racket
|
||||
|
||||
(require file/zip)
|
||||
(require json)
|
||||
(require "visualizer/visual.rkt")
|
||||
(provide (all-from-out "visualizer/visual.rkt"))
|
||||
|
||||
(define modFolder "/mnt/gallery/gameFiles/factorio/mods/")
|
||||
(define serverModFolder "/home/veden/Downloads/factorio/mods/")
|
||||
(define packageName '())
|
||||
(define configuration '())
|
||||
|
||||
(define (makeZip folder)
|
||||
(clear)
|
||||
|
||||
(zip (string-append folder
|
||||
packageName
|
||||
".zip")
|
||||
#:path-prefix packageName
|
||||
(string->path "info.json")
|
||||
(string->path "control.lua")
|
||||
(string->path "data.lua")
|
||||
(string->path "data-updates.lua")
|
||||
(string->path "data-final-fixes.lua")
|
||||
(string->path "COPYING")
|
||||
(string->path "tests.lua")
|
||||
(string->path "changelog.txt")
|
||||
(string->path "settings.lua")
|
||||
(string->path "README.md")
|
||||
(string->path "thumbnail.png")
|
||||
(string->path "NOTICE")
|
||||
(string->path "libs")
|
||||
(string->path "sounds")
|
||||
(string->path "migrations")
|
||||
(string->path "locale")
|
||||
(string->path "graphics")
|
||||
(string->path "prototypes")))
|
||||
|
||||
(define (copyFile fileName modFolder)
|
||||
(copy-file (string->path fileName)
|
||||
(string->path (string-append modFolder
|
||||
packageName
|
||||
"/"
|
||||
fileName))))
|
||||
|
||||
(define (copyDirectory directoryName modFolder)
|
||||
(copy-directory/files (string->path directoryName)
|
||||
(string->path (string-append modFolder
|
||||
packageName
|
||||
"/"
|
||||
directoryName))))
|
||||
|
||||
(define (copyFiles modFolder)
|
||||
(let ((packagePath (string->path (string-append modFolder
|
||||
packageName))))
|
||||
(when (directory-exists? packagePath)
|
||||
(delete-directory/files packagePath))
|
||||
(sleep 0.1)
|
||||
(make-directory packagePath)
|
||||
(copyFile "control.lua" modFolder)
|
||||
(copyFile "info.json" modFolder)
|
||||
(copyFile "data.lua" modFolder)
|
||||
(copyFile "COPYING" modFolder)
|
||||
(copyFile "NOTICE" modFolder)
|
||||
(copyFile "README.md" modFolder)
|
||||
(copyFile "data-updates.lua" modFolder)
|
||||
(copyFile "data-final-fixes.lua" modFolder)
|
||||
(copyFile "settings.lua" modFolder)
|
||||
(copyFile "changelog.txt" modFolder)
|
||||
(copyFile "tests.lua" modFolder)
|
||||
(copyFile "thumbnail.png" modFolder)
|
||||
(copyDirectory "libs" modFolder)
|
||||
(copyDirectory "locale" modFolder)
|
||||
(copyDirectory "migrations" modFolder)
|
||||
(copyDirectory "sounds" modFolder)
|
||||
(copyDirectory "graphics" modFolder)
|
||||
(copyDirectory "prototypes" modFolder)))
|
||||
|
||||
(define (set-metadata)
|
||||
(set! configuration (call-with-input-file "info.json"
|
||||
(lambda (port)
|
||||
(string->jsexpr (port->string port)))))
|
||||
(set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_")
|
||||
"_"
|
||||
(hash-ref configuration 'version))))
|
||||
|
||||
(define (copy)
|
||||
(set-metadata)
|
||||
(copyFiles modFolder)
|
||||
(print (string-append "copying " (hash-ref configuration 'name) (hash-ref configuration 'version))))
|
||||
|
||||
(define (zipIt)
|
||||
(set-metadata)
|
||||
(makeZip modFolder)
|
||||
(print (string-append "zipping " (hash-ref configuration 'name) (hash-ref configuration 'version))))
|
||||
|
||||
(define (clear)
|
||||
(set-metadata)
|
||||
(let ((packagePath (string->path (string-append modFolder
|
||||
packageName
|
||||
".zip")))
|
||||
(unzippedPath (string->path (string-append modFolder
|
||||
packageName))))
|
||||
|
||||
(when (directory-exists? unzippedPath)
|
||||
(delete-directory/files unzippedPath))
|
||||
|
||||
(when (file-exists? packagePath)
|
||||
(delete-file packagePath)))
|
||||
(print (string-append "clearing " (hash-ref configuration 'name) (hash-ref configuration 'version))))
|
||||
|
||||
(let ((arg (vector-ref (current-command-line-arguments) 0)))
|
||||
(cond ((equal? arg "copy") (copy))
|
||||
((equal? arg "zip") (zipIt))
|
||||
((equal? arg "clear") (clear))
|
||||
((equal? arg "visualize") (visualize))
|
||||
(else "Invalid command arg [copy,zip,clear,visualize]")))
|
7
visualizer.sh
Executable file
7
visualizer.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#! /usr/bin/env racket
|
||||
#lang racket
|
||||
|
||||
(require "visualizer/visual.rkt")
|
||||
(provide (all-from-out "visualizer/visual.rkt"))
|
||||
|
||||
(visualize)
|
Loading…
Reference in New Issue
Block a user