Skip to content

Commit 47b9555

Browse files
zephyrisTrueBrain
authored andcommitted
Add: [CI] Set up automatic release workflow
1 parent 081e9b2 commit 47b9555

File tree

5 files changed

+180
-2
lines changed

5 files changed

+180
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "nml",
5+
"pattern": [
6+
{
7+
"regexp": "^.*nmlc (\\w+): \"(.*)\", line (\\d+): (.*)$",
8+
"file": 2,
9+
"line": 3,
10+
"severity": 1,
11+
"message": 4
12+
}
13+
]
14+
}
15+
]
16+
}

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
schedule:
8+
- cron: '0 1 * * 1' # Run every Monday at 01:00 UTC; as GitLFS isn't free, reduce the number of nightlies.
9+
workflow_dispatch:
10+
11+
jobs:
12+
release:
13+
name: Release
14+
uses: TrueBrain/OpenTTD-actions/.github/workflows/rw-entry-release-baseset.yml@baseset-changes
15+
secrets: inherit
16+
with:
17+
apt-packages: git
18+
lfs: true
19+
name: OpenGFX2_Classic
20+
pip-packages: nml pillow blend-modes numpy scikit-image tqdm
21+
problem-matcher: .github/workflows/nml-problem-matcher.json
22+
python-version: "3.13"

docs/building-opengfx2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ These notes are for if you want to build OpenGFX2 from the source files. If you
33

44
Requires `git lfs` for large file handling. Once `git lfs` is installed then clone using `git` as normal.
55

6-
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.
6+
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.
77

88
### To build
99
Clone the repository, navigate to the repository root directory and run `make all`. It will take a long time...

findversion.sh

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/bin/sh
2+
3+
# This file is part of OpenTTD.
4+
# 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.
5+
# 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.
6+
# 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 <http://www.gnu.org/licenses/>.
7+
8+
9+
# Arguments given? Show help text.
10+
if [ "$#" != "0" ]; then
11+
cat <<EOF
12+
Usage: ./findversion.sh
13+
Finds the current revision and if the code is modified.
14+
15+
Output: <VERSION>\t<ISODATE>\t<MODIFIED>\t<HASH>
16+
VERSION
17+
a string describing what version of the code the current checkout is
18+
based on.
19+
This also includes the commit date, an indication of whether the checkout
20+
was modified and which branch was checked out. This value is not
21+
guaranteed to be sortable, but is mainly meant for identifying the
22+
revision and user display.
23+
24+
If no revision identifier could be found, this is left empty.
25+
ISODATE
26+
the commit date of the revision this checkout is based on.
27+
The commit date may differ from the author date.
28+
This can be used to decide upon the age of the source.
29+
30+
If no timestamp could be found, this is left empty.
31+
MODIFIED
32+
Whether (the src directory of) this checkout is modified or not. A
33+
value of 0 means not modified, a value of 2 means it was modified.
34+
35+
A value of 1 means that the modified status is unknown, because this
36+
is not an git checkout for example.
37+
38+
HASH
39+
the git revision hash
40+
41+
By setting the AWK environment variable, a caller can determine which
42+
version of "awk" is used. If nothing is set, this script defaults to
43+
"awk".
44+
EOF
45+
exit 1;
46+
fi
47+
48+
# Allow awk to be provided by the caller.
49+
if [ -z "$AWK" ]; then
50+
AWK=awk
51+
fi
52+
53+
# Find out some dirs
54+
cd `dirname "$0"`
55+
ROOT_DIR=`pwd`
56+
57+
# Determine if we are using a modified version
58+
# Assume the dir is not modified
59+
MODIFIED="0"
60+
if [ -f "$ROOT_DIR/.ottdrev" ]; then
61+
# We are an exported source bundle
62+
cat $ROOT_DIR/.ottdrev
63+
exit
64+
elif [ -d "$ROOT_DIR/.git" ] || [ -f "$ROOT_DIR/.git" ]; then
65+
# We are a git checkout
66+
# Refresh the index to make sure file stat info is in sync, then look for modifications
67+
git update-index --refresh >/dev/null
68+
if [ -n "`git diff-index HEAD`" ]; then
69+
MODIFIED="2"
70+
fi
71+
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
72+
SHORTHASH=`echo ${HASH} | cut -c1-10`
73+
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
74+
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`"
75+
TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`"
76+
77+
if [ "$MODIFIED" -eq "0" ]; then
78+
hashprefix="-g"
79+
elif [ "$MODIFIED" -eq "2" ]; then
80+
hashprefix="-m"
81+
else
82+
hashprefix="-u"
83+
fi
84+
85+
if [ -n "$TAG" ]; then
86+
VERSION="${TAG}"
87+
ISTAG="1"
88+
if [ -n "`echo \"${TAG}\" | grep \"^[0-9.]*$\"`" ]; then
89+
ISSTABLETAG="1"
90+
else
91+
ISSTABLETAG="0"
92+
fi
93+
else
94+
VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}"
95+
ISTAG="0"
96+
ISSTABLETAG="0"
97+
fi
98+
else
99+
# We don't know
100+
MODIFIED="1"
101+
HASH=""
102+
SHORTHASH=""
103+
BRANCH=""
104+
ISODATE=""
105+
TAG=""
106+
VERSION=""
107+
ISTAG="0"
108+
ISSTABLETAG="0"
109+
fi
110+
111+
echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG"

makefile

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
# Always run version detection, so we always have an accurate modified
2+
# flag
3+
REPO_VERSIONS := $(shell AWK="$(AWK)" "./findversion.sh")
4+
REPO_MODIFIED := $(shell echo "$(REPO_VERSIONS)" | cut -f 3 -d' ')
5+
6+
# Use autodetected revisions
7+
REPO_VERSION := $(shell echo "$(REPO_VERSIONS)" | cut -f 1 -d' ')
8+
REPO_DATE := $(shell echo "$(REPO_VERSIONS)" | cut -f 2 -d' ')
9+
REPO_HASH := $(shell echo "$(REPO_VERSIONS)" | cut -f 4 -d' ')
10+
111
# Versions
212
# nice user-facing version naming
3-
NAMING_VERSION := 0.7
13+
NAMING_VERSION := $(REPO_VERSION)
414

515
# Default target
616
.PHONY: all
@@ -142,4 +152,23 @@ clean_graphics:
142152
find graphics -type d -name "__pycache__" -exec rm -rf {} +
143153
rm -rf graphics/fonts/openttd-ttf
144154

155+
# Glue to work like OpenGFX Makefile
156+
.PHONY: maintainer-clean
157+
maintainer-clean: clean
158+
159+
# Glue to work like OpenGFX Makefile
160+
.PHONY: bundle_zip
161+
bundle_zip: baseset/OpenGFX2_Classic-$(NAMING_VERSION).zip
162+
cp baseset/OpenGFX2_Classic-$(NAMING_VERSION).zip OpenGFX2_Classic-$(NAMING_VERSION)-all.zip
163+
164+
# Glue to work like OpenGFX Makefile
165+
.PHONY: bundle_xsrc
166+
bundle_xsrc:
167+
mkdir -p OpenGFX2_Classic-$(NAMING_VERSION)-source
168+
git archive --format=tar HEAD | tar xf - -C OpenGFX2_Classic-$(NAMING_VERSION)-source/
169+
rm -rf OpenGFX2_Classic-$(NAMING_VERSION)-source/.git OpenGFX2_Classic-$(NAMING_VERSION)-source/.gitattributes OpenGFX2_Classic-$(NAMING_VERSION)-source/.gitignore OpenGFX2_Classic-$(NAMING_VERSION)-source/.github
170+
./findversion.sh > OpenGFX2_Classic-$(NAMING_VERSION)-source/.ottdrev
171+
tar -cf OpenGFX2_Classic-$(NAMING_VERSION)-source.tar OpenGFX2_Classic-$(NAMING_VERSION)-source
172+
xz -ef OpenGFX2_Classic-$(NAMING_VERSION)-source.tar
173+
145174
FORCE: ;

0 commit comments

Comments
 (0)