Skip to content

Commit

Permalink
steam CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciberusps committed Jul 8, 2022
1 parent 87868d6 commit 97f49ce
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 133 deletions.
7 changes: 5 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# link on steamworks_sdk.zip file uploaded on google drive, should be created via "npm run steamworks-sdk:zip" that will protect zip with password
STEAM_APP_ID=1904150
STEAMWORKS_SDK_ARCHIVE_PASSWORD=example-password-v$ePa6x4QHN%R8
# link on steamworks_sdk.zip uploaded on google drive, replace FILE_ID with your file id
STEAMWORKS_SDK_GOOGLE_DRIVE_LINK=https://drive.google.com/uc?id=[FILE_ID]&export=download
STEAMWORKS_SDK_ARCHIVE_PASSWORD=example-password-v$ePa6x4QHN%R8#
# link on steamworks_auth_files.zip uploaded on google drive, replace FILE_ID with your file id
STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK=https://drive.google.com/uc?id=[FILE_ID]&export=download
28 changes: 25 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ jobs:
release:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash

env:
STEAMWORKS_SDK_ARCHIVE_PASSWORD: ${{ secrets.STEAMWORKS_SDK_ARCHIVE_PASSWORD }}
STEAMWORKS_SDK_GOOGLE_DRIVE_LINK: ${{ secrets.STEAMWORKS_SDK_GOOGLE_DRIVE_LINK }}
STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK: ${{ secrets.STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK }}

strategy:
matrix:
Expand All @@ -29,9 +34,9 @@ jobs:

- name: Install dependencies
run: |
npm install
npm install --legacy-peer-deps
- name: Publish releases
- name: Publish github releases
env:
# These values are used for auto updates signing
# APPLE_ID: ${{ secrets.APPLE_ID }}
Expand All @@ -43,5 +48,22 @@ jobs:
run: |
npm run postinstall
npm run build
npm exec electron-builder -- --publish always --win
npm exec electron-builder -- --publish always
# npm exec electron-builder -- --publish always --win --mac --linux
- name: Copy release build to steamworks_sdk "content" folder
run: |
cp -r ./release/build/win-unpacked/. ./steamworks_sdk/tools/ContentBuilder/content/
- name: Create steamworks build script
run: node ./scripts/createSteamBuildScript.js
env:
STEAM_APP_ID: 1904150
RELEASE_BRANCH: development

- name: Create auth files
run: node ./scripts/fetchSteamAuthFiles.js

- name: Steam build & release
run: |
"./steamworks_sdk/tools/ContentBuilder/builder/steamcmd.exe" +login ${{ secrets.STEAM_USERNAME }} ${{ secrets.STEAM_PASSWORD }} +run_app_build ../scripts/simple_build.vdf +quit
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,25 @@ You can boost up my motivation/development speed via DonationAlerts - https://ww
## How to update SteamworksSDK

- download steamworks sdk from https://partner.steamgames.com/downloads/list
- extract content from "sdk" folder to "/steamworks_sdk" folder
- extract content from "sdk" folder to `/steamworks_sdk` folder
- fill `STEAMWORKS_SDK_ARCHIVE_PASSWORD` in `.env`
- `npm run steamworks-sdk:zip`
- run 7zip and create archive with password from `steamworks_sdk` folder
- upload `steamworks-sdk:zip` to google drive, make it available to "anyone with the link"(not possible to place zip in git somehow zip brokes after being pushed to any remote same for gitlab and github)
- fill `STEAMWORKS_SDK_GOOGLE_DRIVE_LINK` in `.env` via instructions in `.env.example`
- `npm run steamworks-sdk:unzip` will automatically runned on depenecies install via `npm i`

## How to add "steam auth files" for release on steam via github action

- auth with `./steamworks_sdk/tools/ContentBuilder/builder/steamcmd +login ${steam_login} ${steam_password} +quit`
- fill `STEAMWORKS_SDK_ARCHIVE_PASSWORD` in `.env`
- copy
- `./steamworks_sdk/tools/ContentBuilder/builder/config/config.vdf`
- `./steamworks_sdk/tools/ContentBuilder/builder/ssfn<hashOfNumbers>` only "hidden" required - [how to show hidden files](https://support.microsoft.com/en-us/windows/view-hidden-files-and-folders-in-windows-97fbc472-c603-9d90-91d0-1166d1d9f4b5)
- files to `./steam_auth_files` folder
- open `steam_auth_files` select all files and create .zip password protected archive using 7zip and password from `STEAMWORKS_SDK_ARCHIVE_PASSWORD`
- upload archive on google drive
- fill `STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK` in `.env` via instructions in `.env.example`

### Build

- make some changes
Expand Down
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FireSave",
"version": "0.5.4",
"version": "0.6.0",
"description": "Saves manager",
"main": "./src/main/main.ts",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --config ./electron-builder.json --publish never",
"postinstall": "ts-node .erb/scripts/check-native-dep.js && npm run install:native-deps && electron-builder install-app-deps && cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts && opencollective-postinstall",
"install:native-deps": "cd release/app && npm i --ignore-scripts && cd ../.. && npm run steamworks-sdk:download && npm run steamworks-sdk:unzip",
"install:native-deps": "cd release/app && npm i --ignore-scripts && cd ../.. && node ./scripts/fetchSteamworksSdk.js",
"prepare": "husky install",
"start": "cross-env npm run bump:version $npm_package_version && ts-node ./.erb/scripts/check-port-in-use.js && npm run start:renderer",
"start:main": "cross-env NODE_ENV=development electronmon -r ts-node/register/transpile-only .",
Expand All @@ -21,9 +21,6 @@
"lint:types": "tsc --noEmit",
"test": "jest",
"bump:version": "node scripts/bumpVersion.js",
"steamworks-sdk:download": "node ./scripts/steamworksSdkDownload.js",
"steamworks-sdk:zip": "rm -rf steamworks_sdk.zip && node ./scripts/steamworksSdkZip.js",
"steamworks-sdk:unzip": "node ./scripts/steamworksSdkUnZip.js",
"docs:scrap-greenworks": "node ./scripts/scrapGreensworksDocs.js",
"check:steam-licenses": "npx license-checker > steam-licenses.json --exclude MIT,ISC,Apache-2.0,BSD-3-Clause,WTFPL,CC-BY-4.0,0BSD,Python-2.0,Zlib,BSD-2-Clause,Unlicense"
},
Expand Down Expand Up @@ -155,9 +152,6 @@
"upath": "^2.0.1",
"zustand": "^3.7.2"
},
"engines": {
"npm": "~14.18.3"
},
"devEngines": {
"node": ">=14.x",
"npm": ">=7.x"
Expand Down
46 changes: 4 additions & 42 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FireSave",
"version": "0.5.3",
"version": "0.6.0",
"description": "Saves manager",
"main": "./dist/main/main.js",
"author": {
Expand Down
38 changes: 38 additions & 0 deletions scripts/createSteamBuildScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require("dotenv").config();
const fs = require("fs");
const exec = require("child_process").execSync;

const { checkRequiredEnvs } = require("./utils");

const { STEAM_APP_ID, RELEASE_BRANCH } = process.env;
checkRequiredEnvs(["STEAM_APP_ID", "RELEASE_BRANCH"]);

const packageJson = JSON.parse(fs.readFileSync("package.json"));

const buildScript = `"AppBuild"
{
"AppID" "${STEAM_APP_ID}" // your AppID
"Desc" "v${packageJson.version}" // internal description for this build
"SetLive" "${RELEASE_BRANCH}"
"ContentRoot" "../content/" // root content folder, relative to location of this file
"BuildOutput" "../output/" // build output folder for build logs and build cache files
"Depots"
{
"1904151" // your DepotID
{
"FileMapping"
{
"LocalPath" "*" // all files from contentroot folder
"DepotPath" "." // mapped into the root of the depot
"recursive" "1" // include all subfolders
}
}
}
}`.toString();

fs.writeFileSync(
"./steamworks_sdk/tools/ContentBuilder/scripts/simple_build.vdf",
buildScript
);
25 changes: 25 additions & 0 deletions scripts/fetchSteamAuthFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require("dotenv").config();
const exec = require("child_process").execSync;

const { checkRequiredEnvs } = require("./utils");

const { STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK, STEAMWORKS_SDK_ARCHIVE_PASSWORD } =
process.env;
checkRequiredEnvs([
"STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK",
"STEAMWORKS_SDK_ARCHIVE_PASSWORD",
]);

try {
exec(
`curl -L "${STEAM_AUTH_FILES_GOOGLE_DRIVE_LINK}" > steam_auth_files.zip`
);
console.info("- [fetchSteamAuthFiles] donwloaded");

exec(
`npx 7z-wasm x steam_auth_files.zip -o./steamworks_sdk/tools/ContentBuilder/builder -p${STEAMWORKS_SDK_ARCHIVE_PASSWORD} -aoa`
);
console.info("- [fetchSteamAuthFiles] unzipped");
} catch (err) {
console.error(err);
}
28 changes: 28 additions & 0 deletions scripts/fetchSteamworksSdk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require("dotenv").config();
const exec = require("child_process").execSync;

const { checkRequiredEnvs } = require("./utils");

const { STEAMWORKS_SDK_GOOGLE_DRIVE_LINK, STEAMWORKS_SDK_ARCHIVE_PASSWORD } =
process.env;
checkRequiredEnvs([
"STEAMWORKS_SDK_GOOGLE_DRIVE_LINK",
"STEAMWORKS_SDK_ARCHIVE_PASSWORD",
]);

try {
exec(`curl -L "${STEAMWORKS_SDK_GOOGLE_DRIVE_LINK}" > steamworks_sdk.zip`);
console.info("- [fetchSteamworksSdk] downloaded");

exec(
`npx 7z-wasm x steamworks_sdk.zip -o./release/app/node_modules/greenworks/deps/steamworks_sdk -p${STEAMWORKS_SDK_ARCHIVE_PASSWORD} -aoa`
);
console.info("- [fetchSteamworksSdk] unzipped for greenworks");

exec(
`npx 7z-wasm x steamworks_sdk.zip -o./steamworks_sdk -p${STEAMWORKS_SDK_ARCHIVE_PASSWORD} -aoa`
);
console.info("- [fetchSteamworksSdk] unzipped for steam build");
} catch (err) {
console.error(err);
}
23 changes: 0 additions & 23 deletions scripts/steamworksSdkDownload.js

This file was deleted.

26 changes: 0 additions & 26 deletions scripts/steamworksSdkUnZip.js

This file was deleted.

26 changes: 0 additions & 26 deletions scripts/steamworksSdkZip.js

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function checkRequiredEnvs(envNames) {
const missingEnvs = envNames.filter((env) => !process.env[env]);
if (missingEnvs.length > 0) {
throw new Error(
`Missing required environment variables: ${missingEnvs.join(", ")}`
);
}
}

module.exports = { checkRequiredEnvs };

0 comments on commit 97f49ce

Please sign in to comment.