Skip to content

Commit

Permalink
Setup GitHub CI (#425)
Browse files Browse the repository at this point in the history
* switch from DO to GitHub/prd for editor, engine & asset distribution
* setup GitHub CI for distribution
  • Loading branch information
gajop authored Jul 30, 2022
1 parent b2553ae commit ad8f878
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 12 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/launcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Launcher

on:
push:
paths:
- 'dist_cfg/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-20.04
build_cmd: "build-linux"
arch: "--x64"

- os: windows-latest
build_cmd: "build-win"
arch: "--x64"

steps:
- uses: actions/checkout@v2
with:
# This should fix git rev-list --count HEAD
# https://stackoverflow.com/a/65056108
fetch-depth: 0
path: repo-folder

- uses: actions/checkout@v2
with:
repository: gajop/spring-launcher
path: spring-launcher

- name: Setup NodeJs
uses: actions/setup-node@v1
with:
node-version: '17.x'

- name: Prepare folder structure
run: |
mkdir build
cp spring-launcher/* -r build/
cp repo-folder/dist_cfg/* -r build/src/
mkdir -p build/{bin,files,build}
[ -d build/src/bin/ ] && mv build/src/bin/* build/bin/
[ -d build/src/files/ ] && mv build/src/files/* build/files/
[ -d build/src/build/ ] && mv build/src/build/* build/build/
rm -rf build/src/{bin,files,build}
exit 0
- name: Make package.json
run: |
cd repo-folder
export PACKAGE_VERSION=1.$(git rev-list --count HEAD).0
echo "Making build for version: $PACKAGE_VERSION"
cd ..
node ./repo-folder/build/make_package_json.js build/package.json repo-folder/dist_cfg/config.json Spring-SpringBoard/SpringBoard-Core $PACKAGE_VERSION
- name: Build
run: |
cd build
npm install
npm run ${{ matrix.build_cmd }} -- ${{ matrix.arch }} --publish always
env:
GH_TOKEN: ${{ secrets.github_token }}
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ codes = true
-- Default is probably fine, but anyway
std=lua51

files["libs_sb/utils/luaunit.lua"] = { ignore = {"581"} }

globals = {
-- std extensions
"math.round", "math.bit_or",
Expand Down
39 changes: 39 additions & 0 deletions build/make_package_json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

const fs = require('fs');
const assert = require('assert');

function createPackagejson (packageJson, configJson, repoFullName, version) {
const configStr = fs.readFileSync(configJson);
const config = JSON.parse(configStr);

assert(config.title != null, 'Missing config title');

const repoDotName = repoFullName.replace(/\//g, '.');

const packageTemplate = JSON.parse(fs.readFileSync(packageJson).toString());
packageTemplate.name = config.title.replace(/ /g, '-');
// eslint-disable-next-line no-template-curly-in-string
packageTemplate.build.artifactName = config.title + '-${version}.${ext}'; // '' is used on purpose, we want the spring to contain ${ext} as text
packageTemplate.version = version;
packageTemplate.repository = `github:${repoFullName}`;
packageTemplate.build.appId = `com.springrts.launcher.${repoDotName}`;
packageTemplate.build.publish = undefined;
if (config.dependencies != null) {
for (const dependency in config.dependencies) {
packageTemplate.dependencies[dependency] = config.dependencies[dependency];
}
}

fs.writeFileSync(packageJson, JSON.stringify(packageTemplate), 'utf8');
}

if (require.main === module) {
const args = process.argv;
if (args.length < 6) {
console.log('Wrong arguments');
process.exit(-1);
}

createPackagejson(args[2], args[3], args[4], args[5])
}
22 changes: 11 additions & 11 deletions dist_cfg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"platform": "win32"
},
"downloads": {
"nextgen" : ["Spring-SpringBoard/SpringBoard-Core"],
"games": ["sbc:test"],
"resources": [
{
"url": "https://content.spring-launcher.com/engines/spring_%7Bmaintenance%7D104.0.1-1553-gd3c0012_win32-minimal-portable.7z",
"url": "https://github.com/Spring-SpringBoard/SpringBoard-Resources/releases/download/resources/spring_.maintenance.104.0.1-1553-gd3c0012_win32-minimal-portable.7z",
"destination": "engine/104.0.1-1553-gd3c0012 maintenance",
"extract": true
}
]
},
"launch": {
"game": "rapid://sbc:test",
"games": ["sbc:test"],
"map": "sb_initial_blank_10x8",
"engine": "104.0.1-1553-gd3c0012 maintenance",
"map_options": {
Expand All @@ -41,17 +41,17 @@
"platform": "linux"
},
"downloads": {
"nextgen" : ["Spring-SpringBoard/SpringBoard-Core"],
"games": ["sbc:test"],
"resources": [
{
"url": "https://content.spring-launcher.com/engines/spring_%7Bmaintenance%7D104.0.1-1553-gd3c0012_minimal-portable-linux64-static.7z",
"url": "https://github.com/Spring-SpringBoard/SpringBoard-Resources/releases/download/resources/spring_.maintenance.104.0.1-1553-gd3c0012_minimal-portable-linux64-static.7z",
"destination": "engine/104.0.1-1553-gd3c0012 maintenance",
"extract": true
}
]
},
"launch": {
"game": "rapid://sbc:test",
"games": ["sbc:test"],
"map": "sb_initial_blank_10x8",
"engine": "104.0.1-1553-gd3c0012 maintenance",
"map_options": {
Expand All @@ -71,7 +71,7 @@
"platform": "win32"
},
"downloads": {
"nextgen" : ["Spring-SpringBoard/SpringBoard-Core"],
"games": ["sbc:test"],
"resources": [
{
"url": "https://github.com/beyond-all-reason/spring/releases/download/spring_bar_%7BBAR%7D104.0.1-1977-g12700e0/spring_bar_.BAR.104.0.1-1977-g12700e0_windows-64-minimal-portable.7z",
Expand All @@ -81,7 +81,7 @@
]
},
"launch": {
"game": "rapid://sbc:test",
"games": ["sbc:test"],
"map": "sb_initial_blank_10x8",
"engine": "104.0.1-1977-g12700e0 bar",
"map_options": {
Expand All @@ -101,7 +101,7 @@
"platform": "linux"
},
"downloads": {
"nextgen" : ["Spring-SpringBoard/SpringBoard-Core"],
"games": ["sbc:test"],
"resources": [
{
"url": "https://github.com/beyond-all-reason/spring/releases/download/spring_bar_%7BBAR%7D104.0.1-1977-g12700e0/spring_bar_.BAR.104.0.1-1977-g12700e0_linux-64-minimal-portable.7z",
Expand All @@ -111,7 +111,7 @@
]
},
"launch": {
"game": "rapid://sbc:test",
"games": ["sbc:test"],
"map": "sb_initial_blank_10x8",
"engine": "104.0.1-1977-g12700e0 bar",
"map_options": {
Expand Down Expand Up @@ -172,7 +172,7 @@
"downloads": {
"resources": [
{
"url": "https://content.spring-launcher.com/core_v1.zip",
"url": "https://github.com/Spring-SpringBoard/SpringBoard-Resources/releases/download/resources/core_v1.zip",
"destination": "springboard/assets/core-v1",
"extract": true
}
Expand Down
2 changes: 1 addition & 1 deletion scen_edit/model/model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Model:Clear()
Spring.SetProjectileCollision(projectileID)
end

if not Script.GetName() == "LuaUI" then
if Script.GetName() ~= "LuaUI" then
SB.commandManager:execute(ClearUndoRedoCommand())
end
end
Expand Down

0 comments on commit ad8f878

Please sign in to comment.