diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..4db639b305f5444bce8d2bb611ea9b09daf930f0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,47 @@ +stages: + - build + - upload + - release + +variables: + FC_PREGMOD_HTML: "FC_pregmod_${CI_COMMIT_TAG}.html" + +build: + stage: build + image: debian:latest + rules: + # only for official releases + - if: $CI_COMMIT_TAG =~ /\A\d+\.\d+\.\d+\z/ + script: + - ./compile.sh --ci + artifacts: + paths: + - bin/FC_pregmod.html + +upload: + stage: upload + image: gitgud.io:5050/pregmodfan/fc-pregmod:megacmd + rules: + # only for official releases + - if: $CI_COMMIT_TAG =~ /\A\d+\.\d+\.\d+\z/ + script: + - mega-login $MEGA_MAIL $MEGA_PWD + - mv bin/FC_pregmod.html bin/$FC_PREGMOD_HTML + - mega-put bin/$FC_PREGMOD_HTML / + - echo "MEGA_URL=$(mega-export -a /$FC_PREGMOD_HTML | grep -o https.*)" >> variables.env + artifacts: + # carry MEGA_URL over to the release job + reports: + dotenv: variables.env + +release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + rules: + # only for official releases + - if: $CI_COMMIT_TAG =~ /\A\d+\.\d+\.\d+\z/ + script: + - | + release-cli create --name $CI_COMMIT_TAG --description "Download ${FC_PREGMOD_HTML} to play the game." \ + --tag-name $CI_COMMIT_TAG \ + --assets-link "{\"name\":\"${FC_PREGMOD_HTML}\",\"url\":\"${MEGA_URL}\"}" diff --git a/README.md b/README.md index 6d69d5825ca92ac468ea4326a6ebef598cad6632..f5c3ae4163306031dd695bc9fd43b6f488111d3a 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,11 @@ Pregmod is a modification of the original [Free Cities](https://freecitiesblog.b ## Play the game -To play the game you have to download the sources first. You can either download an archive of the current state or, if -you plan to keep up to date with current progress, clone the repository. +You can download the game over on the [release page](https://gitgud.io/pregmodfan/fc-pregmod/-/releases) -Clone the repo: +Alternatively, you can build the game yourself: + +First, clone the git repository: 1. [Install Git for terminal](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) or a Git GUI of your choice. 2. Clone the repo diff --git a/compile.sh b/compile.sh index 5c6ab810026d650dd61a1a97ce65c845ab272dfd..84b4ee732756fba715c638794adbeac572de3b6e 100755 --- a/compile.sh +++ b/compile.sh @@ -14,6 +14,7 @@ Options: -s, --sanity Run sanityCheck -q, --quiet Suppress terminal output -t, --themes Generate theme files + --ci CI mode HelpText } @@ -66,14 +67,21 @@ function compile() { fi file="bin/FC_pregmod.html" - if [[ -d .git ]]; then - COMMIT=$(git rev-parse --short HEAD) # Find and insert current commit - printf "App.Version.commitHash = '%s';\n" ${COMMIT} > src/002-config/fc-version.js.commitHash.js - if [[ "$usehash" ]]; then + + # Find and insert current commit + if [[ "$ci" ]]; then + COMMIT=$CI_COMMIT_SHORT_SHA + elif [[ -d .git ]]; then + COMMIT=$(git rev-parse --short HEAD) + if [[ "$usehash" ]]; then file="bin/FC_pregmod_${COMMIT}.html" fi fi + if [[ "$COMMIT" ]]; then + printf "App.Version.commitHash = '%s';\n" ${COMMIT} > src/002-config/fc-version.js.commitHash.js + fi + devTools/concatFiles.sh js/ '*.js' bin/fc.js devTools/concatFiles.sh css/ '*.css' bin/fc.css $TWEEGO_EXE -o $file --module=bin/fc.js --module=bin/fc.css --head resources/raster/favicon/arcologyVector.html src/ || build_failed="true" @@ -84,7 +92,7 @@ function compile() { exit 1 fi - if [[ -d .git ]]; then + if [[ "$ci" || -d .git ]]; then rm src/002-config/fc-version.js.commitHash.js fi echoMessage "Saved to $file." @@ -115,6 +123,9 @@ else ;; -t | --themes) themes="true" + ;; + --ci) + ci="true" ;; *) echoError "Unknown argument $1."