Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release workflow behavior #678

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 49 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: Build Redot Project

on:
workflow_dispatch:
inputs:
prerelease:
type: boolean
required: true
description: Whether the release build is a prerelease
env:
BUILD_NAME: official

jobs:
build-linux:
Expand Down Expand Up @@ -290,9 +297,45 @@ jobs:
name: redot-macos-arm64-template
path: redot-macos-arm64-template

- name: Get the current date
id: date
run: echo "CURRENT_DATE=$(date +'%Y%m%d%H')" >> $GITHUB_ENV
- name: Retrieve versioning
run: |
#!/bin/bash

python_script='
import sys
d = {} # create a dict to store values in
exec(open(sys.argv[1], "r").read(), d) # exec code with that dict as namespace
for k in sys.argv[2:]:
print("%s\0" % str(d[k]).split("\0")[0]) # extract values
'

read_python_vars() {
local python_file=$1; shift
local varname
for varname; do
IFS= read -r -d '' "${varname#*:}"
done < <(python -c "$python_script" "$python_file" "${@%%:*}")
}

read_python_vars version.py major:v_major minor:v_minor patch:v_patch status:v_status status_version:v_status_version
v_major=$(echo $v_major|tr -d '\n')
v_minor=$(echo $v_minor|tr -d '\n')
if [ $v_patch = 0 ]; then
v_patch=""
else
v_patch=$(echo $v_patch|tr -d '\n')
v_patch=".$v_patch"
fi
if [ $v_status = "stable" ]; then
v_status="-stable"
v_status_version=""
else
v_status=$(echo $v_status|tr -d '\n')
v_status="-$v_status"
v_status_version=$(echo $v_status_version|tr -d '\n')
v_status_version=".$v_status_version"
fi
echo "CURRENT_VERSION=$v_major.$v_minor$v_patch$v_status$v_status_version" >> $GITHUB_ENV

- name: Zip the dev artifact
run: |
Expand All @@ -305,26 +348,13 @@ jobs:
zip -r redot-macos-x64-template.zip redot-macos-x64-template/*
zip -r redot-macos-arm64-template.zip redot-macos-arm64-template/*

# - name: Upload release artifacts
# uses: actions/upload-artifact@v4
# with:
# name: redot-release-${{ env.CURRENT_DATE }}
# path: |
# redot-linuxbsd.zip
# redot-windowsx64.zip
# redot-macos-x64.zip
# redot-macos-arm64.zip
# redot-linux-template.zip
# redot-windows-template.zip
# redot-macos-x64-template.zip
# redot-macos-arm64-template.zip

- name: Upload dev build artifacts to GitHub dev
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.CURRENT_DATE }}
name: Build ${{ env.CURRENT_DATE }}
tag_name: ${{ env.CURRENT_VERSION }}
name: v${{ env.CURRENT_VERSION }}
draft: false
prerelease: {{ inputs.prerelease }}
make_latest: true
files: |
redot-linuxbsd.zip
Expand Down
1 change: 1 addition & 0 deletions core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def version_info_builder(target, source, env):
#define VERSION_MINOR {minor}
#define VERSION_PATCH {patch}
#define VERSION_STATUS "{status}"
#define VERSION_STATUS_VERSION {status_version}
#define VERSION_BUILD "{build}"
#define VERSION_MODULE_CONFIG "{module_config}"
#define VERSION_WEBSITE "{website}"
Expand Down
10 changes: 9 additions & 1 deletion core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ Dictionary Engine::get_version_info() const {
dict["status"] = VERSION_STATUS;
dict["build"] = VERSION_BUILD;

dict["status_version"] = dict["status"] != "stable" ? VERSION_STATUS_VERSION : 0;

String hash = String(VERSION_HASH);
dict["hash"] = hash.is_empty() ? String("unknown") : hash;

Expand All @@ -135,7 +137,13 @@ Dictionary Engine::get_version_info() const {
if ((int)dict["patch"] != 0) {
stringver += "." + String(dict["patch"]);
}
stringver += "-" + String(dict["status"]) + " (" + String(dict["build"]) + ")";
stringver += "-" + String(dict["status"]);

if ((int)dict["status_version"] != 0) {
stringver += "." + String(dict["status_version"]);
}

stringver += " (" + String(dict["build"]) + ")";
dict["string"] = stringver;

return dict;
Expand Down
11 changes: 6 additions & 5 deletions doc/classes/Engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@
[b]Note:[/b] The [code]hex[/code] value is still an [int] internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for quick version comparisons from code:
[codeblocks]
[gdscript]
if Engine.get_version_info().hex &gt;= 0x040100:
pass # Do things specific to version 4.1 or later.
if Engine.get_godot_compatible_version_info().hex &gt;= 0x040100:
pass # Do things specifically based on Godot version 4.1 compatibility or later.
else:
pass # Do things specific to versions before 4.1.
[/gdscript]
[csharp]
if ((int)Engine.GetVersionInfo()["hex"] &gt;= 0x040100)
if ((int)Engine.GetGodotCompatibleVersionInfo()["hex"] &gt;= 0x040100)
{
// Do things specific to version 4.1 or later.
// Do things specifically based on Godot version 4.1 compatibility or later.
}
else
{
Expand Down Expand Up @@ -228,7 +228,8 @@
- [code]minor[/code] - Minor version number as an int;
- [code]patch[/code] - Patch version number as an int;
- [code]hex[/code] - Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below);
- [code]status[/code] - Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String;
- [code]status[/code] - Status (such as "beta", "rc", "stable", etc.) as a String;
- [code]status_version[/code] - Status version number as an int, [code]0[/code] if status is [code]"stable"[/code];
- [code]build[/code] - Build name (e.g. "custom_build") as a String;
- [code]hash[/code] - Full Git commit hash as a String;
- [code]timestamp[/code] - Holds the Git commit date UNIX timestamp in seconds as an int, or [code]0[/code] if unavailable;
Expand Down
1 change: 1 addition & 0 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def get_version_info(module_version_string="", silent=False):
"minor": int(version.minor),
"patch": int(version.patch),
"status": str(version.status),
"status_version": int(version.status_version),
"build": str(build_name),
"module_config": str(version.module_config) + module_version_string,
"website": str(version.website),
Expand Down
3 changes: 2 additions & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
major = 4
minor = 4
patch = 0
status = "dev"
status = "beta"
status_version = 2
module_config = ""
website = "https://redotengine.org"
docs = "latest"
Expand Down
Loading