Update auto versioning

This commit is contained in:
Nicholas Hastings
2026-07-13 17:55:53 -04:00
parent f1c9faba45
commit 71ceb89241
4 changed files with 43 additions and 5 deletions
+23 -4
View File
@@ -7,8 +7,27 @@ on:
branches: [ master ] branches: [ master ]
jobs: jobs:
version:
name: Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.compute.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Compute version
id: compute
run: |
base_version=$(grep -oP 'SMEXT_CONF_VERSION\s+"\K[^"]+' Extension/sdk/smsdk_config.h)
build_number=$(git rev-list --count HEAD)
echo "version=${base_version}.${build_number}" >> "$GITHUB_OUTPUT"
build: build:
name: sm${{ matrix.sm.label }}-${{ matrix.target.os_name }}-${{ matrix.target.arch }} name: sm${{ matrix.sm.label }}-${{ matrix.target.os_name }}-${{ matrix.target.arch }}
needs: version
runs-on: ${{ matrix.target.os }} runs-on: ${{ matrix.target.os }}
container: ${{ matrix.target.container }} container: ${{ matrix.target.container }}
strategy: strategy:
@@ -78,6 +97,7 @@ jobs:
--mms-path ../mmsource \ --mms-path ../mmsource \
--steamworks-path ../SteamworksSDK \ --steamworks-path ../SteamworksSDK \
--target ${{ matrix.target.arch }} \ --target ${{ matrix.target.arch }} \
--version "${{ needs.version.outputs.version }}" \
--enable-optimize --enable-optimize
ambuild ambuild
@@ -91,6 +111,7 @@ jobs:
--mms-path ../mmsource \ --mms-path ../mmsource \
--steamworks-path ../SteamworksSDK \ --steamworks-path ../SteamworksSDK \
--target ${{ matrix.target.arch }} \ --target ${{ matrix.target.arch }} \
--version "${{ needs.version.outputs.version }}" \
--enable-optimize --enable-optimize
ambuild ambuild
@@ -138,7 +159,7 @@ jobs:
release: release:
name: Release name: Release
needs: build needs: [version, build]
if: github.event_name == 'push' && github.ref == 'refs/heads/master' if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@@ -157,9 +178,7 @@ jobs:
- name: Assemble packages - name: Assemble packages
id: package id: package
run: | run: |
base_version=$(grep -oP 'SMEXT_CONF_VERSION\s+"\K[^"]+' Extension/sdk/smsdk_config.h) version="${{ needs.version.outputs.version }}"
build_number=$(git rev-list --count HEAD)
version="${base_version}-git${build_number}"
echo "version=${version}" >> "$GITHUB_OUTPUT" echo "version=${version}" >> "$GITHUB_OUTPUT"
# One package per SourceMod version per OS: Windows as .zip, Linux as # One package per SourceMod version per OS: Windows as .zip, Linux as
+6
View File
@@ -69,6 +69,12 @@ binary = SteamWorks.HL2Config(project, builder.cxx, 'SteamWorks.ext')
# The Steam API headers all come from the SteamWorks SDK; the extension is built # The Steam API headers all come from the SteamWorks SDK; the extension is built
# with META_NO_HL2SDK, so no HL2SDK is required. # with META_NO_HL2SDK, so no HL2SDK is required.
binary.compiler.defines += ['META_NO_HL2SDK', 'SOURCEMOD_BUILD', 'VERSION_SAFE_STEAM_API_INTERFACES'] binary.compiler.defines += ['META_NO_HL2SDK', 'SOURCEMOD_BUILD', 'VERSION_SAFE_STEAM_API_INTERFACES']
# Let CI bake the generated release version into the binary. The value is passed
# as an unquoted token and stringized in smsdk_config.h, avoiding shell-quoting
# differences between MSVC and gcc/clang.
if builder.options.version:
binary.compiler.defines += ['SMEXT_CONF_VERSION_OVERRIDE={0}'.format(builder.options.version)]
binary.compiler.cxxincludes += [os.path.join(SteamWorks.steamworks_root, 'public', 'steam')] binary.compiler.cxxincludes += [os.path.join(SteamWorks.steamworks_root, 'public', 'steam')]
binary.compiler.cxxincludes += [os.path.join(SteamWorks.sm_root, 'public', 'safetyhook', 'include')] binary.compiler.cxxincludes += [os.path.join(SteamWorks.sm_root, 'public', 'safetyhook', 'include')]
+12 -1
View File
@@ -40,7 +40,18 @@
/* Basic information exposed publicly */ /* Basic information exposed publicly */
#define SMEXT_CONF_NAME "SteamWorks Extension" #define SMEXT_CONF_NAME "SteamWorks Extension"
#define SMEXT_CONF_DESCRIPTION "Exposes SteamWorks functions to Developers" #define SMEXT_CONF_DESCRIPTION "Exposes SteamWorks functions to Developers"
#define SMEXT_CONF_VERSION "1.2.3" /* The literal below is the MAJOR.MINOR base and the version used by local builds.
CI turns it into a full MAJOR.MINOR.PATCH release version by defining
SMEXT_CONF_VERSION_OVERRIDE at build time as an unquoted token (e.g. 1.2.158,
where the patch is the commit count); it is stringized here so no cross-platform
shell quoting is required. Bump the MAJOR/MINOR here by hand. */
#if defined(SMEXT_CONF_VERSION_OVERRIDE)
#define SMEXT_CONF_VERSION_STR_(x) #x
#define SMEXT_CONF_VERSION_STR(x) SMEXT_CONF_VERSION_STR_(x)
#define SMEXT_CONF_VERSION SMEXT_CONF_VERSION_STR(SMEXT_CONF_VERSION_OVERRIDE)
#else
#define SMEXT_CONF_VERSION "1.2"
#endif
#define SMEXT_CONF_AUTHOR "Kyle Sanderson, AlliedModders" #define SMEXT_CONF_AUTHOR "Kyle Sanderson, AlliedModders"
#define SMEXT_CONF_URL "https://github.com/alliedmodders/SM-SteamWorks" #define SMEXT_CONF_URL "https://github.com/alliedmodders/SM-SteamWorks"
#define SMEXT_CONF_LOGTAG "STEAMWORKS" #define SMEXT_CONF_LOGTAG "STEAMWORKS"
+2
View File
@@ -30,4 +30,6 @@ run.options.add_argument('--enable-debug', action='store_const', const='1', dest
run.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt', run.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
help='Enable optimization') help='Enable optimization')
run.options.add_argument('--target', default=None, help='Override the default build target') run.options.add_argument('--target', default=None, help='Override the default build target')
run.options.add_argument('--version', type=str, dest='version', default=None,
help='Override the version string baked into the binary (defaults to the literal in smsdk_config.h)')
run.Configure() run.Configure()