Northstar/.github/workflows/build.yml

217 lines
9.1 KiB
YAML

name: Build
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
job:
description: 'Job to run'
required: true
default: 'build-thunderstore-package'
permissions:
contents: write # Needed to write to GitHub draft release
env:
NORTHSTAR_VERSION: ${{ github.ref_name }}
jobs:
build-launcher:
runs-on: windows-2022
steps:
- name: Checkout launcher repository
uses: actions/checkout@v3
with:
repository: R2Northstar/NorthstarLauncher
ref: ${{ env.NORTHSTAR_VERSION }}
path: northstar-launcher
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1
- name: Setup resource file version
shell: bash
working-directory: northstar-launcher
run: |
sed -i 's/DEV/${{ env.NORTHSTAR_VERSION }}/g' NorthstarLauncher/resources.rc
FILEVERSION=$(echo ${{ env.NORTHSTAR_VERSION }} | tr '.' ',' | sed -E 's/-rc[0-9]+//' | tr -d '[:alpha:]')
sed -i "s/0,0,0,1/${FILEVERSION}/g" NorthstarDLL/ns_version.h
- name: Build Launcher
working-directory: northstar-launcher
run: |
msbuild /p:Configuration=Release R2Northstar.sln
- name: Upload launcher build as artifact
uses: actions/upload-artifact@v3
with:
name: northstar-launcher
path: |
northstar-launcher/x64/Release/Northstar.dll
northstar-launcher/x64/Release/wsock32.dll
northstar-launcher/x64/Release/NorthstarLauncher.exe
northstar-launcher/x64/Release/*.txt
- name: Upload debug build artifact
uses: actions/upload-artifact@v3
with:
name: launcher-debug-files
path: |
northstar-launcher/x64/Release/*.pdb
build-northstar:
needs: build-launcher
runs-on: ubuntu-20.04
steps:
- name: Download compiled launcher
uses: actions/download-artifact@v3
with:
name: northstar-launcher
path: northstar-launcher
- name: Download DiscordRPC plugin
run:
wget "https://github.com/R2Northstar/NorthstarDiscordRPC/releases/download/v4/northstar-discord-rpc.zip"
- name: Download compiled stubs
run:
wget "https://github.com/R2Northstar/NorthstarStubs/releases/download/v1/NorthstarStubs.zip"
- name: Checkout release files
uses: actions/checkout@v3
with:
ref: ${{ env.NORTHSTAR_VERSION }}
path: northstar
- name: Checkout core mods
uses: actions/checkout@v3
with:
repository: R2Northstar/NorthstarMods
ref: ${{ env.NORTHSTAR_VERSION }}
path: northstar-mods
- name: Update mod version info
run: |
export MOD_VERSION=$(echo $NORTHSTAR_VERSION | tr -d 'v')
cat <<< $(jq ".Version = \"${MOD_VERSION}\"" northstar-mods/Northstar.Client/mod.json) > northstar-mods/Northstar.Client/mod.json
cat <<< $(jq ".Version = \"${MOD_VERSION}\"" northstar-mods/Northstar.Custom/mod.json) > northstar-mods/Northstar.Custom/mod.json
cat <<< $(jq ".Version = \"${MOD_VERSION}\"" northstar-mods/Northstar.CustomServers/mod.json) > northstar-mods/Northstar.CustomServers/mod.json
- name: Generate md5sum file
working-directory: northstar-mods
run: |
echo -e "# Check with 'md5sum -c md5sum.txt' at the root of mods folder\n" > md5sum.txt
git ls-tree -r $NORTHSTAR_VERSION --name-only | xargs -L1 md5sum >> md5sum.txt
- name: Make folder structure
run: |
mv -v northstar/release/* northstar/.
rm -d release
mkdir -p northstar/R2Northstar/mods
mkdir -p northstar/R2Northstar/plugins
mkdir -p northstar/bin/x64_retail
unzip northstar-discord-rpc.zip
mv -v DiscordRPC.dll northstar/R2Northstar/plugins
mv -v northstar-launcher/wsock32.dll northstar/bin/x64_retail
unzip NorthstarStubs.zip -d northstar/bin/x64_dedi
mv -v northstar-launcher/* northstar
rsync -avr --exclude="Northstar.Coop" --exclude=".git*" northstar-mods/. northstar/R2Northstar/mods
- name: Checkout Navmesh repository
uses: actions/checkout@v3
with:
repository: R2Northstar/NorthstarNavs
ref: 'v1'
path: northstar-navs
- name: Navmeshes setup
run: |
mkdir -p northstar/R2Northstar/mods/Northstar.CustomServers/mod/maps
mv -v northstar-navs/graphs northstar/R2Northstar/mods/Northstar.CustomServers/mod/maps
mv -v northstar-navs/navmesh northstar/R2Northstar/mods/Northstar.CustomServers/mod/maps
- name: Cleanup root Northstar repository files
working-directory: northstar
run: |
rm -rf .git .github .gitignore *.md LICENSE thunderstore .ci.env.example
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Northstar.release.${{ env.NORTHSTAR_VERSION }}
path: northstar
- name: Create zip to upload
run: |
cd northstar/
zip --recurse-paths --quiet Northstar.release.${{ env.NORTHSTAR_VERSION }}.zip .
mv Northstar.release.${{ env.NORTHSTAR_VERSION }}.zip ../
- name: Compute SHA-512 checksum
run: |
sha512sum Northstar.release.${{ env.NORTHSTAR_VERSION }}.zip
- name: Upload zip to release draft
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v') && !contains(env.NORTHSTAR_VERSION, '-rc')
with:
draft: true
files: Northstar.release.${{ env.NORTHSTAR_VERSION }}.zip
build-thunderstore-package:
needs: build-northstar # comment out when running locally
env:
# Release envs, comment this out when running locally
TCLI_AUTH_TOKEN: ${{ secrets.THUNDERSTORE_TOKEN }}
TS_REPO: https://thunderstore.io/
TS_COMMUNITY: northstar
# Uncomment when testing locally, must be unique
# NORTHSTAR_VERSION: 0.1.8
# Thunderstore info and descriptions
TS_NAMESPACE: northstar
TS_MOD_NAME: Northstar
TS_MOD_DESCRIPTION: Titanfall 2 modding and custom server framework.
runs-on: ubuntu-20.04
steps:
- name: Setup tcli
run: |
wget -O tcli.tar.gz https://github.com/thunderstore-io/thunderstore-cli/releases/download/0.1.4/tcli-0.1.4-linux-x64.tar.gz
tar xvf tcli.tar.gz
sudo mv -v tcli-0.1.4-linux-x64/tcli /bin
- name: (DEBUG) Download Northstar package
if: ${{ env.ACT }} # Download Northstar package from releases when running locally instead of relying on previous jobs
run: |
wget -O northstar.zip https://github.com/R2Northstar/Northstar/releases/download/v1.6.3/Northstar.release.v1.6.3.zip
unzip northstar.zip -d northstar
- name: Download Northstar package
if: ${{ !env.ACT }} # Download artifacts from previous jobs when running on GitHub's infrastructure
uses: actions/download-artifact@v3
with:
name: Northstar.release.${{ env.NORTHSTAR_VERSION }}
path: northstar
- name: Make package structure
run: |
mkdir -p thunderstore/dist/Northstar
mv -v northstar/* thunderstore/dist/Northstar
wget -O thunderstore/icon.png https://raw.githubusercontent.com/R2Northstar/Northstar/main/thunderstore/icon.png
wget -O thunderstore/README.md https://raw.githubusercontent.com/R2Northstar/Northstar/main/thunderstore/README.md
- name: Setup environment variables
run: |
# Strip leading `v` and if exists replace `-rc` with `0` and strip leading zeroes from last semver digit if necessary
echo "MOD_VERSION=$(echo $NORTHSTAR_VERSION | tr -d 'v'| sed --expression 's/-rc/0/' | sed -E 's/([0-9]+)\.([0-9]+)\.(0*)([0-9])/\1.\2.\4/;')" >> $GITHUB_ENV
# If it's a release candidate we also want to change a few things
if [[ $NORTHSTAR_VERSION == *"-rc"* ]]; then
# We want to push to a different package
# i.e. `NorthstarReleaseCandidate` vs `Northstar`
echo "TS_MOD_NAME=NorthstarReleaseCandidate" >> $GITHUB_ENV
# And update mod description
echo "TS_MOD_DESCRIPTION=Release candidate for next Northstar release." >> $GITHUB_ENV
# Add disclaimer add the top of README
echo -e '> ⚠️ This is a release candidate. Please report bugs or other issues on GitHub ⚠️\n' | cat - thunderstore/README.md > temp && mv temp thunderstore/README.md
fi
- name: Publish package to Thunderstore
working-directory: thunderstore
run: |
tcli init --package-name=$TS_MOD_NAME --package-namespace=$TS_NAMESPACE --package-version $MOD_VERSION
sed -i "s/communities = \[\]/communities = [\"$TS_COMMUNITY\"]/g" thunderstore.toml
sed -i "s/Example-Dependency = \"1.0.0\"//g" thunderstore.toml
sed -i "s/description = \"Example mod description\"/description = \"$TS_MOD_DESCRIPTION\"/g" thunderstore.toml
cat thunderstore.toml
tcli build
tcli publish --repository "$TS_REPO" --file build/*.zip