From 25ccf040c5d3564cd22252f4c609df2871e509bf Mon Sep 17 00:00:00 2001 From: hikari_no_yume Date: Fri, 2 Jan 2026 01:37:49 +0100 Subject: [PATCH] Enable building true release builds with GitHub Actions Change-Id: I86a908c608a9b6b8dd5b37f182f0ada93545c739 --- .github/workflows/touchHLE_release.yml | 40 ++++++++++++++++++++------ src/lib.rs | 2 +- src/version/lib.rs | 9 ++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/touchHLE_release.yml b/.github/workflows/touchHLE_release.yml index 20992abee..16b271e86 100644 --- a/.github/workflows/touchHLE_release.yml +++ b/.github/workflows/touchHLE_release.yml @@ -5,6 +5,7 @@ on: branches: [ "trunk" ] pull_request: branches: [ "trunk" ] + create: # for tags env: CARGO_TERM_COLOR: always @@ -15,9 +16,16 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # touchHLE's git-describe versioning needs tag history + # actions/checkout really doesn't work well with git-describe for some + # reason (most likely it strips the annotation off the tag somehow). + - name: Checkout touchHLE + shell: bash # windows :) + run: | + mkdir -p "$GITHUB_WORKSPACE" + git clone https://github.com/touchHLE/touchHLE "$GITHUB_WORKSPACE" + cd "$GITHUB_WORKSPACE" + git fetch origin "$GITHUB_REF" + git checkout "$GITHUB_SHA" # avoid race condition if branch/tag changes - name: Install clang-format run: brew install clang-format - name: Check formatting @@ -85,9 +93,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # touchHLE's git-describe versioning needs tag history + # actions/checkout really doesn't work well with git-describe for some + # reason (most likely it strips the annotation off the tag somehow). + - name: Checkout touchHLE + shell: bash # windows :) + run: | + mkdir -p "$GITHUB_WORKSPACE" + git clone https://github.com/touchHLE/touchHLE "$GITHUB_WORKSPACE" + cd "$GITHUB_WORKSPACE" + git fetch origin "$GITHUB_REF" + git checkout "$GITHUB_SHA" # avoid race condition if branch/tag changes - name: Check formatting run: dev-scripts/format.sh --check - name: Get Submodules @@ -176,9 +191,16 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # touchHLE's git-describe versioning needs tag history + # actions/checkout really doesn't work well with git-describe for some + # reason (most likely it strips the annotation off the tag somehow). + - name: Checkout touchHLE + shell: bash # windows :) + run: | + mkdir -p "$GITHUB_WORKSPACE" + git clone https://github.com/touchHLE/touchHLE "$GITHUB_WORKSPACE" + cd "$GITHUB_WORKSPACE" + git fetch origin "$GITHUB_REF" + git checkout "$GITHUB_SHA" # avoid race condition if branch/tag changes # Apparently the Windows runner already has clang-format? That's nice. - name: Check formatting shell: bash # no command output without this diff --git a/src/lib.rs b/src/lib.rs index cbaa9f197..b37916e17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,7 +122,7 @@ pub fn main>(mut args: T) -> Result<(), String> { if branding().is_empty() { "" } else { " " }, VERSION, ); - if GITHUB_RUN_ID.is_some() { + if GITHUB_RUN_ID.is_some() && !branding().is_empty() { echo!( "Built from branch {:?} of {:?} by GitHub Actions workflow run {}/{}/actions/runs/{}.", GITHUB_REF_NAME.unwrap(), diff --git a/src/version/lib.rs b/src/version/lib.rs index b6ae7a44d..ff5a09d74 100644 --- a/src/version/lib.rs +++ b/src/version/lib.rs @@ -10,11 +10,20 @@ pub const GITHUB_REPOSITORY: Option<&str> = option_env!("GITHUB_REPOSITORY"); pub const GITHUB_SERVER_URL: Option<&str> = option_env!("GITHUB_SERVER_URL"); pub const GITHUB_RUN_ID: Option<&str> = option_env!("GITHUB_RUN_ID"); pub const GITHUB_REF_NAME: Option<&str> = option_env!("GITHUB_REF_NAME"); +pub const GITHUB_EVENT_NAME: Option<&str> = option_env!("GITHUB_EVENT_NAME"); pub fn branding() -> &'static str { if GITHUB_RUN_ID.is_none() { return ""; } + if GITHUB_EVENT_NAME == Some("create") + && VERSION + .strip_prefix('v') + .is_some_and(|v| v == env!("CARGO_PKG_VERSION")) + && GITHUB_REF_NAME.unwrap() == VERSION + { + return ""; + } if (GITHUB_REPOSITORY, GITHUB_REF_NAME) == (Some("touchHLE/touchHLE"), Some("trunk")) { "PREVIEW" } else {