Skip to content

Commit

Permalink
Add updated build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurihaia committed Apr 14, 2024
1 parent 3049025 commit 1860bd4
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 114 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ resharper_web_config_wrong_module_highlighting = warning
indent_style = space
indent_size = 4
tab_width = 4

[*.{yaml,yml}]
indent_size = 2
tab_width = 2
indent_style = space
194 changes: 91 additions & 103 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,119 +1,107 @@
name: build

on: [push, pull_request]
on:
push:
pull_request:

jobs:
build-win:
build:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [windows, macos, linux]
archive-ref: [main]
steps:
- uses: actions/checkout@v3
- name: Setup Vanilla
run: |
wget https://files.catbox.moe/i4sdl6.zip -O Vanilla.zip
unzip Vanilla.zip -d Vanilla
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Setup ms-build
run: sudo apt-get install -y nuget mono-devel mono-xbuild
- name: Restore dependencies
run: dotnet restore
- name: Build PrePatcher
run: |
dotnet build PrePatcher -o PrePatcher/Output -p:Configuration=Release
- name: Build Assembly-CSharp (Windows)
run: |
dotnet build Assembly-CSharp -p:SolutionDir=$PWD -p:Configuration=Release
- name: Upload Windows Binary
uses: actions/upload-artifact@v3
with:
name: ModdingApiWin
path: ./OutputFinal/

build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Vanilla
run: |
wget https://files.catbox.moe/j85bvb.zip -O Vanilla.zip
unzip Vanilla.zip -d Vanilla
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Setup ms-build
run: sudo apt-get install -y nuget mono-devel mono-xbuild
- name: Restore dependencies
run: dotnet restore
- name: Build PrePatcher
run: |
dotnet build PrePatcher -o PrePatcher/Output -p:Configuration=Release
- name: Build Assembly-CSharp
run: |
dotnet build Assembly-CSharp -p:SolutionDir=$PWD -p:Configuration=Release
- name: Upload Linux Binary
uses: actions/upload-artifact@v3
with:
name: ModdingApiLinux
path: ./OutputFinal/

build-mac:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Vanilla
run: |
wget https://files.catbox.moe/j8fyro.zip -O Vanilla.zip
unzip Vanilla.zip -d Vanilla
- name: Setup .NET
uses: actions/setup-dotnet@v3
- name: Setup ms-build
run: sudo apt-get install -y nuget mono-devel mono-xbuild
- name: Restore dependencies
run: dotnet restore
- name: Build PrePatcher
run: |
dotnet build PrePatcher -o PrePatcher/Output -p:Configuration=Release
- name: Build Assembly-CSharp
run: |
dotnet build Assembly-CSharp -p:SolutionDir=$PWD -p:Configuration=Release
- name: Upload Mac Binary
uses: actions/upload-artifact@v3
with:
name: ModdingApiMac
path: ./OutputFinal/

- uses: actions/checkout@v4

- name: Read Versions
run: |
HKV=$(cat ./hollowknight.version)
echo "HK_VERSION=$HKV" >> $GITHUB_ENV
- name: Checkout Binaries
uses: actions/checkout@v4
with:
repository: hk-modding/hk-binary-archives
ref: ${{ matrix.archive-ref }}
ssh-key: ${{ secrets.BINARY_ARCHIVE_DEPLOY_KEY }}
sparse-checkout: |
${{ env.HK_VERSION }}/managed.${{ matrix.platform }}.tar.gz
sparse-checkout-cone-mode: false
path: ./hk-binary-archives

- name: Unpack Archive
run: |
mkdir Vanilla
cd ./Vanilla
tar -xzf ../hk-binary-archives/${{ env.HK_VERSION }}/managed.${{ matrix.platform }}.tar.gz
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup MSBuild
run: |
sudo apt-get update -y
sudo apt-get install -y nuget mono-devel mono-xbuild
- name: Restore Dependencies
run: |
dotnet restore
- name: Build PrePatcher
run: |
dotnet build PrePatcher -o PrePatcher/Output -p:Configuration=Release
- name: Build Assembly-CSharp
run: |
dotnet build Assembly-CSharp -p:SolutionDir=$PWD -p:Configuration=Release
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: build.${{ matrix.platform }}
path: ./OutputFinal/

release:
needs: [build-win, build-linux, build-mac]
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Read Versions
run: |
HKV=$(cat ./hollowknight.version)
echo "HK_VERSION=$HKV" >> $GITHUB_ENV
APIV=$(cat ./moddingapi.version)
echo "API_VERSION=$APIV" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Zip
- name: Zip Artifacts
run: |
zip -jr ModdingApiWin.zip ./artifacts/ModdingApiWin/*
zip -jr ModdingApiLinux.zip ./artifacts/ModdingApiLinux/*
zip -jr ModdingApiMac.zip ./artifacts/ModdingApiMac/*
- name: Generate release info
zip -jr moddingapi.${{ env.API_VERSION }}.windows.zip ./artifacts/build.windows/*
zip -jr moddingapi.${{ env.API_VERSION }}.macos.zip ./artifacts/build.macos/*
zip -jr moddingapi.${{ env.API_VERSION }}.linux.zip ./artifacts/build.linux/*
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install Node Dependencies
run: |
echo "# Checksums" > ChangeLog.txt ;
echo "* Linux:" >> ChangeLog.txt ;
echo -n " * " >> ChangeLog.txt ;
sha256sum -b ModdingApiLinux.zip | cut -d " " -f 1 >> ChangeLog.txt ;
echo "* Mac:" >> ChangeLog.txt ;
echo -n " * " >> ChangeLog.txt ;
sha256sum -b ModdingApiMac.zip | cut -d " " -f 1 >> ChangeLog.txt ;
echo "* Windows:" >> ChangeLog.txt ;
echo -n " * " >> ChangeLog.txt ;
sha256sum -b ModdingApiWin.zip | cut -d " " -f 1 >> ChangeLog.txt ;
echo "# Changelog" >> ChangeLog.txt ;
echo "${{ github.event.head_commit.message }}" >> ChangeLog.txt ;
- name: Create release if a new tag is pushed
uses: softprops/action-gh-release@v1
npm install handlebars
- name: Create Release Notes
id: create-relnotes
uses: actions/github-script@v7
env:
CHANGELOG: ${{ github.event.head_commit.message }}
with:
result-encoding: string
script: |
const script = require("./.github/workflows/create_relnotes.js");
return await script();
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: ChangeLog.txt
body: ${{ steps.create-relnotes.outputs.result }}
files: |
./ModdingApiWin.zip
./ModdingApiLinux.zip
./ModdingApiMac.zip
./moddingapi.${{ env.API_VERSION }}.windows.zip
./moddingapi.${{ env.API_VERSION }}.macos.zip
./moddingapi.${{ env.API_VERSION }}.linux.zip
36 changes: 36 additions & 0 deletions .github/workflows/create_relnotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// @ts-check
/** @param {import('github-script').AsyncFunctionArguments} args */
module.exports = async ({ github, core }) => {
const handlebars = require("handlebars");
const fs = require("node:fs/promises");
const crypto = require("node:crypto");

const { HK_VERSION, API_VERSION, CHANGELOG } = process.env;

const relnotes = await fs.readFile("./.github/workflows/release_notes.md", { encoding: "utf-8" });
const template = handlebars.compile(relnotes);

const artifact_windows = await fs.readFile(`./moddingapi.${API_VERSION}.windows.zip`);
const artifact_macos = await fs.readFile(`./moddingapi.${API_VERSION}.macos.zip`);
const artifact_linux = await fs.readFile(`./moddingapi.${API_VERSION}.linux.zip`);

const hash_windows = crypto.createHash("sha256");
hash_windows.update(artifact_windows);

const hash_macos = crypto.createHash("sha256");
hash_macos.update(artifact_macos);

const hash_linux = crypto.createHash("sha256");
hash_linux.update(artifact_linux);

const output = template({
api_version: API_VERSION,
hk_version: HK_VERSION,
changelog: CHANGELOG,
windows_cs: hash_windows.digest("hex"),
macos_cs: hash_macos.digest("hex"),
linux_cs: hash_linux.digest("hex"),
});

return output;
};
24 changes: 13 additions & 11 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@ on:

jobs:
docfx:
if: github.event_name == 'push'
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout docs
uses: actions/checkout@v2
- name: Checkout Repository
uses: actions/checkout@v4
- name: Checkout `docs` branch
uses: actions/checkout@v4
with:
ref: docs
path: docs
- name: Setup .NET
uses: actions/setup-dotnet@v1
- name: Setup ms-build, mono
run: sudo apt-get install -y nuget mono-devel mono-xbuild
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup MSBuild
run: |
sudo apt-get update -y
sudo apt-get install -y nuget mono-devel mono-xbuild
- name: Download DocFX
working-directory: docs
run: |
wget https://github.com/dotnet/docfx/releases/download/v2.59.4/docfx.zip -O docfx.zip
unzip docfx.zip -d docfx
- name: Build docs
- name: Build Documentation
working-directory: docs
run: |
mono docfx/docfx.exe
- name: Publish
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: DocFX
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/release_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ModdingAPI {{api_version}} for Hollow Knight {{hk_version}}

### Changelog

{{changelog}}

### Checksums
* Windows: `{{windows_cs}}`
* MacOS: `{{macos_cs}}`
* Linux: `{{linux_cs}}`
1 change: 1 addition & 0 deletions Assembly-CSharp/ModHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Modding
[PublicAPI]
public class ModHooks
{
// Make sure this is in sync with `/moddingapi.version`.
private const int _modVersion = 74;

private static readonly string SettingsPath = Path.Combine(Application.persistentDataPath, "ModdingApi.GlobalSettings.json");
Expand Down
1 change: 1 addition & 0 deletions hollowknight.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5.78.11833
1 change: 1 addition & 0 deletions moddingapi.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v74

0 comments on commit 1860bd4

Please sign in to comment.