Skip to content

Update build configuration to use actions/checkout@v6 and streamline … #7

Update build configuration to use actions/checkout@v6 and streamline …

Update build configuration to use actions/checkout@v6 and streamline … #7

Workflow file for this run

name: Build
on:
push:
pull_request:
jobs:
build:
runs-on: windows-2022
permissions:
contents: write
env:
LAUNCHER_PATH: target\i686-win7-windows-msvc\release\HMCLauncher.exe
RUST_TOOLCHAIN: nightly-2026-04-16
HMCL_VERSION: 3.13.1
steps:
- uses: actions/checkout@v6
- name: Get short SHA
shell: pwsh
run: echo "SHORT_SHA=$("${{ github.sha }}".Substring(0, 7))" >> $env:GITHUB_ENV
- name: Setup Rust
shell: pwsh
run: rustup toolchain install $env:RUST_TOOLCHAIN --profile minimal --component rust-src
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: "17"
java-package: jdk+fx
cache: gradle
- name: Build HMCLauncher
shell: pwsh
run: |
cargo build --release --locked
Copy-Item -Path $env:LAUNCHER_PATH -Destination target\HMCLauncher-${{ env.SHORT_SHA }}.exe
- name: Upload HMCLauncher exe
uses: actions/upload-artifact@v7
with:
name: HMCLauncher.exe
path: target\HMCLauncher-${{ env.SHORT_SHA }}.exe
archive: false
- name: Download HMCL jar
shell: pwsh
run: |
$jarFileName = "HMCL-$env:HMCL_VERSION.jar"
$downloadUrl = "https://github.com/HMCL-dev/HMCL/releases/download/v$env:HMCL_VERSION/$jarFileName"
Invoke-WebRequest -Uri $downloadUrl -OutFile "target\$jarFileName"
- name: Create HMCL exe
shell: pwsh
run: |
$exeBytes = [System.IO.File]::ReadAllBytes($env:LAUNCHER_PATH)
$jarBytes = [System.IO.File]::ReadAllBytes("target\HMCL-$env:HMCL_VERSION.jar")
$mergedBytes = $exeBytes + $jarBytes
[System.IO.File]::WriteAllBytes("target\HMCL-$env:HMCL_VERSION.$env:SHORT_SHA.exe", $mergedBytes)
- name: Upload HMCL exe
uses: actions/upload-artifact@v7
with:
name: HMCL.exe
path: target\HMCL-${{ env.HMCL_VERSION }}.${{ env.SHORT_SHA }}.exe
archive: false
- name: Create release
if: ${{ github.ref_type == 'tag' }}
uses: softprops/action-gh-release@v2
with:
files: |
target/i686-win7-windows-msvc/release/HMCLauncher.exe
target/i686-win7-windows-msvc/release/HMCLauncher.exe.sha256