diff --git a/.github/workflows/nml-problem-matcher.json b/.github/workflows/nml-problem-matcher.json new file mode 100644 index 00000000..befa749b --- /dev/null +++ b/.github/workflows/nml-problem-matcher.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "nml", + "pattern": [ + { + "regexp": "^.*nmlc (\\w+): \"(.*)\", line (\\d+): (.*)$", + "file": 2, + "line": 3, + "severity": 1, + "message": 4 + } + ] + } + ] +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..cb08ea37 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Release + +on: + release: + types: + - published + schedule: + - cron: '0 1 * * 1' # Run every Monday at 01:00 UTC; as GitLFS isn't free, reduce the number of nightlies. + workflow_dispatch: + +jobs: + release: + name: Release + uses: OpenTTD/actions/.github/workflows/rw-entry-release-baseset.yml@v5 + secrets: inherit + with: + apt-packages: git + lfs: true + name: opengfx2_classic + pip-packages: nml pillow blend-modes numpy scikit-image tqdm + problem-matcher: .github/workflows/nml-problem-matcher.json + python-version: "3.13" diff --git a/.gitignore b/.gitignore index da13d0d4..321847eb 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ previews/ # temporary files for pip *.tmp + +# outputs for CI +opengfx2_classic-* diff --git a/docs/building-opengfx2.md b/docs/building-opengfx2.md index e21f2b11..0f6670b2 100644 --- a/docs/building-opengfx2.md +++ b/docs/building-opengfx2.md @@ -3,7 +3,7 @@ These notes are for if you want to build OpenGFX2 from the source files. If you Requires `git lfs` for large file handling. Once `git lfs` is installed then clone using `git` as normal. -Requires a system with `make`, `nmlc`, `git` and `python3` with `PIL`, `blend-modes`, `numpy`, `skimage`, `tqdm`. This has been developed using Windows Subsystem for Linux (WSL) and might have peculiarities (eg. incorrect file permissions) on a real Linux install. +Requires a system with `make`, `nmlc`, `git` and `python3` (3.11+) with `PIL`, `blend-modes`, `numpy`, `scikit-image`, `tqdm`. This has been developed using Windows Subsystem for Linux (WSL) and might have peculiarities (eg. incorrect file permissions) on a real Linux install. ### To build Clone the repository, navigate to the repository root directory and run `make all`. It will take a long time... diff --git a/findversion.sh b/findversion.sh new file mode 100755 index 00000000..cd610400 --- /dev/null +++ b/findversion.sh @@ -0,0 +1,111 @@ +#!/bin/sh + +# This file is part of OpenTTD. +# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. +# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + + +# Arguments given? Show help text. +if [ "$#" != "0" ]; then + cat <\t\t\t +VERSION + a string describing what version of the code the current checkout is + based on. + This also includes the commit date, an indication of whether the checkout + was modified and which branch was checked out. This value is not + guaranteed to be sortable, but is mainly meant for identifying the + revision and user display. + + If no revision identifier could be found, this is left empty. +ISODATE + the commit date of the revision this checkout is based on. + The commit date may differ from the author date. + This can be used to decide upon the age of the source. + + If no timestamp could be found, this is left empty. +MODIFIED + Whether (the src directory of) this checkout is modified or not. A + value of 0 means not modified, a value of 2 means it was modified. + + A value of 1 means that the modified status is unknown, because this + is not an git checkout for example. + +HASH + the git revision hash + +By setting the AWK environment variable, a caller can determine which +version of "awk" is used. If nothing is set, this script defaults to +"awk". +EOF +exit 1; +fi + +# Allow awk to be provided by the caller. +if [ -z "$AWK" ]; then + AWK=awk +fi + +# Find out some dirs +cd `dirname "$0"` +ROOT_DIR=`pwd` + +# Determine if we are using a modified version +# Assume the dir is not modified +MODIFIED="0" +if [ -f "$ROOT_DIR/.ottdrev" ]; then + # We are an exported source bundle + cat $ROOT_DIR/.ottdrev + exit +elif [ -d "$ROOT_DIR/.git" ] || [ -f "$ROOT_DIR/.git" ]; then + # We are a git checkout + # Refresh the index to make sure file stat info is in sync, then look for modifications + git update-index --refresh >/dev/null + if [ -n "`git diff-index HEAD`" ]; then + MODIFIED="2" + fi + HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null` + SHORTHASH=`echo ${HASH} | cut -c1-10` + ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'` + BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`" + TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`" + + if [ "$MODIFIED" -eq "0" ]; then + hashprefix="-g" + elif [ "$MODIFIED" -eq "2" ]; then + hashprefix="-m" + else + hashprefix="-u" + fi + + if [ -n "$TAG" ]; then + VERSION="${TAG}" + ISTAG="1" + if [ -n "`echo \"${TAG}\" | grep \"^[0-9.]*$\"`" ]; then + ISSTABLETAG="1" + else + ISSTABLETAG="0" + fi + else + VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}" + ISTAG="0" + ISSTABLETAG="0" + fi +else + # We don't know + MODIFIED="1" + HASH="" + SHORTHASH="" + BRANCH="" + ISODATE="" + TAG="" + VERSION="" + ISTAG="0" + ISSTABLETAG="0" +fi + +echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG" diff --git a/makefile b/makefile index 535516e1..6098a8dd 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,17 @@ +# Always run version detection, so we always have an accurate modified +# flag +REPO_VERSIONS := $(shell AWK="$(AWK)" "./findversion.sh") +REPO_MODIFIED := $(shell echo "$(REPO_VERSIONS)" | cut -f 3 -d' ') + +# Use autodetected revisions +REPO_VERSION := $(shell echo "$(REPO_VERSIONS)" | cut -f 1 -d' ') +REPO_DATE := $(shell echo "$(REPO_VERSIONS)" | cut -f 2 -d' ') +REPO_HASH := $(shell echo "$(REPO_VERSIONS)" | cut -f 4 -d' ') + # Versions # nice user-facing version naming -NAMING_VERSION := 0.7 +NAMING_VERSION := $(REPO_VERSION) +NAMING_CDN := opengfx2_classic # Default target .PHONY: all @@ -142,4 +153,23 @@ clean_graphics: find graphics -type d -name "__pycache__" -exec rm -rf {} + rm -rf graphics/fonts/openttd-ttf +# Glue to work like OpenGFX Makefile +.PHONY: maintainer-clean +maintainer-clean: clean + +# Glue to work like OpenGFX Makefile +.PHONY: bundle_zip +bundle_zip: baseset/OpenGFX2_Classic-$(NAMING_VERSION).zip + cp baseset/OpenGFX2_Classic-$(NAMING_VERSION).zip $(NAMING_CDN)-$(NAMING_VERSION)-all.zip + +# Glue to work like OpenGFX Makefile +.PHONY: bundle_xsrc +bundle_xsrc: + mkdir -p $(NAMING_CDN)-$(NAMING_VERSION)-source + git archive --format=tar HEAD | tar xf - -C $(NAMING_CDN)-$(NAMING_VERSION)-source/ + rm -rf $(NAMING_CDN)-$(NAMING_VERSION)-source/.git $(NAMING_CDN)-$(NAMING_VERSION)-source/.gitattributes $(NAMING_CDN)-$(NAMING_VERSION)-source/.gitignore $(NAMING_CDN)-$(NAMING_VERSION)-source/.github + ./findversion.sh > $(NAMING_CDN)-$(NAMING_VERSION)-source/.ottdrev + tar -cf $(NAMING_CDN)-$(NAMING_VERSION)-source.tar $(NAMING_CDN)-$(NAMING_VERSION)-source + xz -ef $(NAMING_CDN)-$(NAMING_VERSION)-source.tar + FORCE: ;