Skip to content

Commit

Permalink
Remove the emergency version and commit ID
Browse files Browse the repository at this point in the history
When the version system was designed, we envisioned two types of release:
* Stable releases 3.0, 3.1, 3.2, etc.
* Pre-releases 3.0-alpha.1 etc.

In addition, we wanted to show a commit id in various places for intermediate
builds. The code was written to change the C++ side of things as little as
possible, which resulted in some hacks being used. In practice, we don't
strictly follow this scheme since we publish patch releases to the stable, e.g.
3.0.2.

This patch removes a hack and code we don't need:
* Support for emergency versions (we just release a new minor if needed)
* Support for commit SHAs (it was hacky)

The release documentation is also updated with the new expected tag format
(three digits without -stable for stable releases).
  • Loading branch information
lmoureaux authored and jwrober committed Feb 4, 2024
1 parent fbbe730 commit ddda37f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 33 deletions.
25 changes: 10 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,23 @@ include(AutoRevision)
# Set some variables from AutoRevision for use here and later
list(LENGTH FC21_REV_TAG_LIST FC21_REV_TAG_LIST_LENGTH)

# When we tag a stable release we only get 2 of the 4 components populated
# So we manually set some of the variables we need for the full version.
if(${FC21_REV_TAG_LIST_LENGTH} EQUAL 2)
# When we tag a stable release we only get 3 of the 4 components populated,
# so we manually set some of the variables we need for the full version.
if (${FC21_REV_TAG_LIST_LENGTH} EQUAL 3)
list(GET FC21_REV_TAG_LIST 0 FC21_MAJOR_VERSION)
list(GET FC21_REV_TAG_LIST 1 FC21_MINOR_VERSION)
set(FC21_LABEL_VERSION "Stable")
set(FC21_EMER_VERSION "0")
set(FC21_PATCH_VERSION "0")
list(GET FC21_REV_TAG_LIST 2 FC21_PATCH_VERSION)
set(FC21_VERSION_LABEL "stable")
set(IS_STABLE_VERSION true)
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}")
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}.${FC21_PATCH_VERSION}")
else()
message(STATUS "${FC21_REV_TAG_LIST}")
list(GET FC21_REV_TAG_LIST 0 FC21_MAJOR_VERSION)
list(GET FC21_REV_TAG_LIST 1 FC21_MINOR_VERSION)
list(GET FC21_REV_TAG_LIST 2 FC21_LABEL_VERSION)
if (${FC21_REV_TAG_LIST_LENGTH} GREATER 3)
list(GET FC21_REV_TAG_LIST 3 FC21_EMER_VERSION)
else()
set(FC21_EMER_VERSION 0)
endif()
set(FC21_PATCH_VERSION ${FC21_REV_HEAD_HASH_D})
list(GET FC21_REV_TAG_LIST 2 FC21_VERSION_LABEL)
list(GET FC21_REV_TAG_LIST 3 FC21_PATCH_VERSION)
set(IS_STABLE_VERSION false)
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}.${FC21_PATCH_VERSION}")
set(FREECIV21_VERSION "${FC21_MAJOR_VERSION}.${FC21_MINOR_VERSION}")
endif()

# Set project
Expand Down
2 changes: 1 addition & 1 deletion client/packhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void handle_server_join_reply(bool you_can_join, const char *message,
}

client_info._obsolete = 5; // Old value for gui_type(GUI_QT)
client_info.emerg_version = EMERGENCY_VERSION;
client_info._obsolete2 = 0;
qstrncpy(client_info.distribution, FREECIV_DISTRIBUTOR,
sizeof(client_info.distribution));
send_packet_client_info(&client.conn, &client_info);
Expand Down
5 changes: 3 additions & 2 deletions common/networking/packets.def
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,8 @@ end

PACKET_SERVER_INFO = 29; sc, dsend
STRING version_label[48];
UINT32 major_version, minor_version, patch_version, emerg_version;
UINT32 major_version, minor_version, patch_version;
UINT32 _obsolete; # Since 3.1
end

/************** City packets **********************/
Expand Down Expand Up @@ -1291,7 +1292,7 @@ end

PACKET_CLIENT_INFO = 119; cs, handle-per-conn
UINT8 _obsolete;
UINT32 emerg_version;
UINT32 _obsolete2; # Since 3.1
STRING distribution[MAX_LEN_NAME];
end

Expand Down
7 changes: 4 additions & 3 deletions docs/Contributing/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ These are the general steps to prepare and finalize a release:
`branches page <https://github.com/longturn/freeciv21/branches>`_.
#. From the same page, create a new ``stable`` branch from ``master``.
#. Update ``cmake/AutoRevision.txt`` with the hash of the last commit in ``master`` and
``v[major version].[minor version]-dev`` with the version of the :strong:`next stable release`, then
``v[major version].[minor version]-dev.0`` with the version of the :strong:`next stable release`, then
open a PR for this change to ``master``. This way, development builds from ``master`` will immediately
use the version number of the next stable.

#. If the release is a :strong:`release candidate` for a :strong:`stable release`, the release manager will
make sure that the :guilabel:`Target` branch in the release draft is set to ``stable``.
#. The release manager will add a tag to the release notes page and then click :guilabel:`Publish Release`.
The format of the tag is ``v[major version].[minor version]-[pre-release name].[number]``. For example:
``v3.0-beta.6``. :strong:`The format is very important` to the build configuration process.
The format of the tag is ``v[major version].[minor version]-[pre-release name].[number]`` for pre-releases
and ``v[major version].[minor version].[patch version]`` for stable versions. For example:
``v3.0-beta.6`` or ``v3.1.0``. :strong:`The format is very important` to the build configuration process.
#. After a few minutes the continuous integration (CI) will open a PR titled
``Release Update of AutoRevision.txt``. The release manager will open the PR, click on the
:guilabel:`Close pull request` button, and then click :guilabel:`Open pull request` button. This is a
Expand Down
2 changes: 1 addition & 1 deletion server/connecthand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ bool handle_login_request(struct connection *pconn,
info.major_version = MAJOR_VERSION;
info.minor_version = MINOR_VERSION;
info.patch_version = PATCH_VERSION;
info.emerg_version = EMERGENCY_VERSION;
info._obsolete = 0;
sz_strlcpy(info.version_label, VERSION_LABEL);
send_packet_server_info(pconn, &info);
}
Expand Down
1 change: 0 additions & 1 deletion server/savegame/savegame3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2375,7 +2375,6 @@ static void sg_save_scenario(struct savedata *saving)

game_version =
MAJOR_VERSION * 1000000 + MINOR_VERSION * 10000 + PATCH_VERSION * 100;
game_version += EMERGENCY_VERSION;
secfile_insert_int(saving->file, game_version, "scenario.game_version");

if (!saving->scenario || !game.scenario.is_scenario) {
Expand Down
16 changes: 6 additions & 10 deletions utility/fc_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
#define MAJOR_VERSION @FC21_MAJOR_VERSION@
#define MINOR_VERSION @FC21_MINOR_VERSION@
#define PATCH_VERSION @FC21_PATCH_VERSION@
#define EMERGENCY_VERSION @FC21_EMER_VERSION@
#ifndef VERSION_LABEL
#define VERSION_LABEL "-@FC21_LABEL_VERSION@"
#endif
#define VERSION_LABEL "-@FC21_VERSION_LABEL@"

#cmakedefine01 IS_STABLE_VERSION
#ifndef VERSION_STRING
# if IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@"
# else // IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@.@FC21_PATCH_VERSION@.@FC21_EMER_VERSION@-@FC21_LABEL_VERSION@"
# endif
#if IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@.@FC21_PATCH_VERSION@"
#else // IS_STABLE_VERSION
# define VERSION_STRING "@FC21_MAJOR_VERSION@.@FC21_MINOR_VERSION@-@FC21_VERSION_LABEL@.@FC21_PATCH_VERSION@"
#endif

#define NETWORK_CAPSTRING \
Expand Down

0 comments on commit ddda37f

Please sign in to comment.