Skip to content

Commit

Permalink
Merge pull request #48 from ChrisAdderley/dev
Browse files Browse the repository at this point in the history
Release 0.8.14
  • Loading branch information
ChrisAdderley authored Jan 17, 2019
2 parents 5f430a1 + bf35ad1 commit 0a0c4c9
Show file tree
Hide file tree
Showing 16 changed files with 786 additions and 31 deletions.
23 changes: 1 addition & 22 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
build_scripts/* linguist-vendored
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,12 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg

# Specific items for packaging scripts
*.pyc
.idea/
build/
tmp/
deploy/
build_scripts/version.txt
build_scripts/changelog.md
60 changes: 60 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
language: python
python:
- 3.6
install:
- pip install awscli boto3 requests requests_toolbelt
branches:
only:
- master
script:
- python build_scripts/build.py
before_deploy:
- VERSION=$(cat build_scripts/version.txt)
- CHANGELOG=$(cat build_scripts/changelog.md)
- IFS='/'; BASENAME=($TRAVIS_REPO_SLUG); unset IFS;
- RELEASE_NAME="${BASENAME[1]} $VERSION"
- echo $VERSION
- git config --local user.name "ChrisAdderley"
- git config --local user.email "[email protected]"
- git remote set-url origin https://ChrisAdderley:${GITHUB_OAUTH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git
# Only tag if this is the first before_deploy (runs for all providers)
- >
if ! [ "$BEFORE_DEPLOY_RUN" ]; then
export BEFORE_DEPLOY_RUN=1;
git tag $VERSION;
git push origin $VERSION;
fi
deploy:
- provider: script
script: python build_scripts/deploy.py --curse
skip_cleanup: true
on:
condition: $TRAVIS_BRANCH = master
- provider: script
script: python build_scripts/deploy.py --spacedock
skip_cleanup: true
on:
condition: $TRAVIS_BRANCH = master
- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
bucket: "nertea-ksp-modding-releases"
local_dir: deploy
skip_cleanup: true
acl: public_read
region: us-east-2
upload-dir: near-future-solar
on:
condition: $TRAVIS_BRANCH = master
- deploy:
provider: releases
api_key: $GITHUB_OAUTH_TOKEN
file_glob: true
file: deploy/*
# Disabled because newlines break it
#body: "$CHANGELOG"
name: $RELEASE_NAME
skip_cleanup: true
on:
tags: false
condition: $TRAVIS_BRANCH = master
8 changes: 4 additions & 4 deletions GameData/NearFutureSolar/Versioning/NearFutureSolar.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
{
"MAJOR":0,
"MINOR":8,
"PATCH":13,
"PATCH":14,
"BUILD":0
},
"KSP_VERSION":
{
"MAJOR":1,
"MINOR":5,
"MINOR":6,
"PATCH":1
},
"KSP_VERSION_MIN":{
"MAJOR":1,
"MINOR":5,
"MINOR":6,
"PATCH":0
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":5,
"MINOR":6,
"PATCH":99
}
}
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Near Future Solar

A mod pack for Kerbal Space Program, delivering a lot of new solar panel models

* [Features](#features)
* [Dependencies](#dependencies)
* [Installation](#installation)
* [Optional Patches](#optional-patches)
* [External Compatibility](#features)
* [Contributing](#contributing)

## Features

Bigger, better or just different solar panel models based on many real or imagined concepts

* **Concentrating Solar Arrays**: Heavier arrays that deliver more power per unit mass
* **Blanket Solar Arrays**: Giant arrays that deliver tons of power
* **Wraparaound Arrays**: Wraparaound solar arrays for 1.25, 2.5 and 3.75m footprints, including extending versions

## Dependencies

### Required
These components are required for the mod to function and are bundled as part of any download:
* [ModuleManager (3.1.3)](https://github.com/sarbian/ModuleManager)

## Installation

To install, place the GameData folder inside your Kerbal Space Program folder. If asked to overwrite files, please do so.

NOTE: Do NOT rename or move folders within the GameData folder - this mod uses absolute paths to assets and will break if this happens.

## External Mod Compatibility

This mod includes compatibility patches for the following mods:
* [KSP-AVC](https://github.com/CYBUTEK/KSPAddonVersionChecker): Provides version checking
* [Community Tech Tree](https://github.com/ChrisAdderley/CommunityTechTree): Provides an expanded, community-sourced technology tree for modders to use

## Contributing

I certainly accept pull requests. Please target all such things to the `dev` branch though!

## Licensing

The art assets in this pack (all .dds, .png and .mu files) are distributed under an All Rights Reserved license. You may not redistribute or re-use these assets without express permission from the author.

Any bundled mods are distributed under their own licenses:
* ModuleManager by ialdabaoth and sarbian is distributed under a Creative Commons Sharealike license. More details, including source code, can be found [here](http://forum.kerbalspaceprogram.com/threads/31342-0-20-ModuleManager-1-3-for-all-your-stock-modding-needs?p=528607&viewfull=1#post528607)

Everything else is distributed under the MIT license.

Copyright (c) 2019 Chris Adderley
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
160 changes: 160 additions & 0 deletions build_scripts/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Build script entrypoint
import os
import shutil
import zipfile
import zlib
import sys
from argparse import ArgumentParser

from build_support.build_helpers import *
from build_support.dependencies import download_dependency


# Build paths
TEMP_PATH = "tmp"
BUILD_PATH = "build"
DEPLOY_PATH = "deploy"

# Root directoy files to keep in the archives
VALID_FILES = ["changelog.txt", "readme.txt"]

def build_nodep_release(version_data, mod_name):
"""
Builds the release zip with no included dependencies
Inputs:
version_data (dict): Contents of the .version file
mod_name (str): name of the mod
"""
build_path = os.path.join(DEPLOY_PATH,
f"{mod_name}_Core_" + "{MAJOR}_{MINOR}_{PATCH}".format(**version_data["VERSION"]))
shutil.make_archive(build_path, 'zip', os.path.join(BUILD_PATH))
print(f"> Built {build_path}")

def build_full_release(version_data, mod_name):
"""
Builds the release zip with a full set of required dependencies
Inputs:
version_data (dict): Contents of the .version file
mod_name (str): name of the mod
"""
build_path = os.path.join(DEPLOY_PATH,
f"{mod_name}_" + "{MAJOR}_{MINOR}_{PATCH}".format(**version_data["VERSION"]))
shutil.make_archive(build_path, 'zip', os.path.join(BUILD_PATH))
print(f"> Built {build_path}")

def build_extras(version_data, build_packages=False):
"""
Compiles and optionally builds packages for all Extras in the mod
Inputs:
version_data (dict): Contents of the .version file
build_packages (bool): whether to create an individual zipfile for each package
"""
dirs = [name for name in os.listdir("Extras") if os.path.isdir(os.path.join("Extras", name))]

for name in dirs:
build_extra(name, version_data, build_packages)

def build_extra(name, version_data, build_package):
"""
Compiles and optionally builds a single Extras package
Inputs:
name (str): name of the extra
version_data (dict): Contents of the .version file
build_package (bool): whether to create an individual zipfile for the package
"""
extra_path = os.path.join(DEPLOY_PATH, f"{name}" + "{MAJOR}_{MINOR}_{PATCH}".format(**version_data["VERSION"]))
print(f"> Compiling Extra {name}")
ensure_path(os.path.join(BUILD_PATH,"Extras"))
shutil.copytree(os.path.join("Extras", name), os.path.join(BUILD_PATH,"Extras", name))

if build_package:
print(f"> Building {name}")
shutil.make_archive(extra_path, "zip", os.path.join(BUILD_PATH, "Extras", name))
print(f"> Built {extra_path}")

def collect_dependencies(dep_data):
"""
Finds and downloads all the mod's dependencies
Inputs:
dep_data (dict): dictionart of dependecies from build_data.json
"""
clean_path(TEMP_PATH)
for name, info in dep_data.items():
download_dependency(name, info, TEMP_PATH, BUILD_PATH)
cleanup()

def cleanup():
"""
Cleans up the trailing files in the main directory for packaging by excluding all expect the
specified items in VALID_FILES
"""
onlyfiles = [f for f in os.listdir(BUILD_PATH) if os.path.isfile(os.path.join(BUILD_PATH, f))]
for f in onlyfiles:
if f not in VALID_FILES:
os.remove(os.path.join(BUILD_PATH,f))

def bundle(core_release, extras_release, complete_release):
"""
Compiles and builds the set of release packages according to information from
the .version file and the build_data.json file
"""
# Collect build information
build_data = get_build_data()
version_data = get_version_file_info(build_data["mod_name"])

print(f"Building {build_data['mod_name']} version {get_version(version_data)}\n=================")

# Clean/recreate the build, deploy and temp paths
clean_path(os.path.join(BUILD_PATH))
clean_path(os.path.join(DEPLOY_PATH))
clean_path(os.path.join(TEMP_PATH))

# Copy main mod content
print(f"Compiling core mod content")
shutil.copytree(os.path.join("GameData", build_data["mod_name"]), os.path.join(BUILD_PATH, "GameData", build_data["mod_name"]))
shutil.copy("changelog.txt", os.path.join(BUILD_PATH, "changelog.txt"))
shutil.copy("readme.txt", os.path.join(BUILD_PATH, "readme.txt"))

if core_release:
print(f"Building BASIC release package")
build_nodep_release(version_data, build_data['mod_name'])

if os.path.exists("Extras"):
print(f"Compiling and building EXTRAS release packages")
build_extras(version_data, extras_release)

print(f"Compiling complete release package")
print(f"> Collecting dependencies")
collect_dependencies(build_data["dependencies"])

if complete_release:
print(f"Building COMPLETE release package")
build_full_release(version_data, build_data['mod_name'])

# Write the version/changelog out in text for Travis deploy scripts to take advantage of as env variables set are not persisted
with open(os.path.join("build_scripts", 'version.txt'), "w") as f:
f.write(get_version(version_data))

with open(os.path.join("build_scripts", 'changelog.md'), "w") as f:
f.write(get_changelog())

if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("-c", "--complete",
action="store_true", default=True,
help="write complete package")
parser.add_argument("-e", "--extras",
action="store_true", default=False,
help="write extras package")
parser.add_argument("-b", "--basic",
action="store_true", default=False,
help="write basic no dependency package")

args = parser.parse_args()

bundle(args.basic, args.extras, args.complete)
20 changes: 20 additions & 0 deletions build_scripts/build_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"mod_name": "NearFutureSolar",
"dependencies":
{
"ModuleManager":
{
"version": "3.1.3",
"location": "s3"
}
},
"spacedock":
{
"mod-id": 559
},
"curseforge":
{
"mod-id": 220672
}

}
Empty file.
Loading

0 comments on commit 0a0c4c9

Please sign in to comment.