Enable building true release builds with GitHub Actions

Change-Id: I86a908c608a9b6b8dd5b37f182f0ada93545c739
This commit is contained in:
hikari_no_yume
2026-01-02 01:37:49 +01:00
parent a81667131e
commit 25ccf040c5
3 changed files with 41 additions and 10 deletions

View File

@@ -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

View File

@@ -122,7 +122,7 @@ pub fn main<T: Iterator<Item = String>>(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(),

View File

@@ -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 {