从 GitHub Actions 直接构建并发布游戏到 Steam
NULL on error 比特翻转的同时更新像素
从 GitHub Actions 直接构建并发布游戏到 Steam
2025年3月23日
我一直在工作和个人项目中使用大量的 GitHub Actions,正如这篇文章所示 What I’ve been automating with GitHub Actions, an automated life。
在空闲时间,我正在开发一款2D捉迷藏游戏,正如你所期望的那样,我已经自动化了在 Steam 上发布的整个发布流程。 经过几次尝试,当它最终起作用时,感觉就像魔法一样:我所要做的就是创建一个新标签,几分钟之内,Steam 客户端就会下载更新。
正如我之前提到的,我有一个2D引擎,虽然很简单,但功能相当全面。对于每个新标签,我都会为 Windows、macOS、Linux 和 WebAssembly 并行编译它。 编译完成后,我创建一个 release 并在 GitHub 上发布它。Releases · willtobyte/carimbo
就像这样:
name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
release:
runs-on: ${{ matrix.config.os }}
permissions:
contents: write
strategy:
fail-fast: true
matrix:
config:
- name: macOS
os: macos-latest
- name: Ubuntu
os: ubuntu-latest
- name: WebAssembly
os: ubuntu-latest
- name: Windows
os: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Dependencies
uses: actions/cache@v4
with:
path: |
~/.conan2/p
C:/Users/runneradmin/.conan2/p
key: ${{ matrix.config.name }}-${{ hashFiles('**/conanfile.py') }}
restore-keys: |
${{ matrix.config.name }}-
- name: Prepare Build Directory
run: mkdir build
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Conan
run: pip install conan
- name: Detect Conan Profile
run: conan profile detect --force
- name: Set Conan Center
run: conan remote update conancenter --url https://center2.conan.io
- name: Detect WebAssembly Conan Profile
if: matrix.config.name == 'WebAssembly'
run: |
cat > ~/.conan2/profiles/webassembly <<EOF
include(default)
[settings]
arch=wasm
os=Emscripten
[tool_requires]
*: emsdk/3.1.73
EOF
- name: Install Windows Or macOS Dependencies
if: matrix.config.name == 'Windows' || matrix.config.name == 'macOS'
run: conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 --settings build_type=Release
- name: Install Ubuntu Dependencies
if: matrix.config.name == 'Ubuntu'
run: conan install . --output-folder=build --build=missing --settings compiler.cppstd=20 --settings build_type=Release --conf "tools.system.package_manager:mode=install" --conf "tools.system.package_manager:sudo=True"
- name: Install WebAssembly Dependencies
if: matrix.config.name == 'WebAssembly'
run: conan install . --output-folder=build --build=missing --profile=webassembly --settings compiler.cppstd=20 --settings build_type=Release
- name: Configure
run: cmake .. -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release
working-directory: build
- name: Build
run: cmake --build . --parallel 8 --config Release --verbose
working-directory: build
- name: Create Artifacts Directory
run: mkdir artifacts
- name: Compress Artifacts
if: matrix.config.name == 'macOS'
working-directory: build
run: |
chmod -R a+rwx carimbo
tar -cpzvf macOS.tar.gz carimbo
mv macOS.tar.gz ../artifacts
- name: Compress Artifacts
if: matrix.config.name == 'Ubuntu'
working-directory: build
run: |
chmod +x carimbo
tar -czvf Ubuntu.tar.gz --mode='a+rwx' carimbo
mv Ubuntu.tar.gz ../artifacts
- name: Compress Artifacts
if: matrix.config.name == 'WebAssembly'
working-directory: build
run: |
zip -jr WebAssembly.zip carimbo.wasm carimbo.js
mv WebAssembly.zip ../artifacts
- name: Compress Artifacts
if: matrix.config.name == 'Windows'
working-directory: build
shell: powershell
run: |
Compress-Archive -LiteralPath 'Release/carimbo.exe' -DestinationPath "../artifacts/Windows.zip"
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tagName }}
prerelease: ${{ github.events.inputs.prerelease }}
files: artifacts/*
在 Steam 上发布非常简单。首先,你需要一个拥有正确文档并已支付费用的开发者帐户。 之后,你需要生成一些密钥,如下所示:
steamcmd +login <username> <password> +quit
如果你没有安装 steamcmd
应用程序,你需要使用以下命令安装它:
cast install --cask steamcmd
复制身份验证文件的内容:
cat ~/Library/Application\ Support/Steam/config/config.vdf | base64 | pbcopy
**注意:**你必须启用 MFA。登录后,运行以下命令并将输出复制到名为 STEAM_CONFIG_VDF
的 GitHub Action 变量中。
另外,创建变量 STEAM_USERNAME
,值为你的用户名,以及 STEAM_APP_ID
,值为你的游戏 ID。
此外,该 Action 仅下载最新的 Carimbo Windows 版本(对不起 Linux 和 macOS 用户,我的时间有限)。 理想情况下,我应该使用类似 runtime.txt
文件的东西来固定运行时版本(Carimbo 版本)。 也许我将来会实现这一点,但目前,一切都在使用最前沿的版本。 :-)
on:
push:
tags:
- "v*.*.*"
jobs:
publish:
runs-on: ubuntu-latest
env:
CARIMBO_TAG: "v1.0.65"
permissions:
contents: write
steps:
- name: Clone the repository
uses: actions/checkout@v4
- name: Install 7zip
run: sudo apt install p7zip-full
- name: Create bundle
run: 7z a -xr'!.git/*' -xr'!.git' -xr'!.*' -t7z -m0=lzma -mx=6 -mfb=64 -md=32m -ms=on bundle.7z .
- name: Download Carimbo runtime
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release download ${{ env.CARIMBO_TAG }} --repo willtobyte/carimbo --pattern "Windows.zip"
- name: Extract Carimbo runtime
run: 7z x Windows.zip -o.
- name: Copy files
run: |
mkdir -p output
mv bundle.7z output/
mv carimbo.exe output/
- name: Upload build to Steam
uses: game-ci/steam-deploy@v3
with:
username: ${{ secrets.STEAM_USERNAME }}
configVdf: ${{ secrets.STEAM_CONFIG_VDF }}
appId: ${{ secrets.STEAM_APP_ID }}
rootPath: output
depot1Path: "."
releaseBranch: prerelease
成了!如果一切正确,你的游戏应该会出现在你的 Steam 客户端的已拥有游戏列表中。
相关内容
-
My First Game with Carimbo, My Homemade Engine, For my Son 2024年10月08日
-
How I saved a few dozen dollars by migrating my personal projects from the cloud to a Raspberry Pi 2024年6月05日
-
My 2024 Setup 2024年3月20日
© 2025 by Rodrigo Delduca