Skip to content

Removed some useless comment #3

Removed some useless comment

Removed some useless comment #3

Workflow file for this run

name: Build tModLoader
env:
DevBranch: 1.4.4
StableBranch: stable
PreviewBranch: preview
IsRelease: ${{ github.event_name == 'push' && (contains(github.ref, 'preview') || contains(github.ref, 'stable')) }}
IsVersioned: ${{ github.event_name == 'push' && (contains(github.ref, 'preview') || contains(github.ref, 'stable') || contains(github.ref, '1.4.4')) }}
# Controls when the action will run.
on:
# This workflow runs when a push to major branch happens, or when a label is added to a pull request targetting major branch.
push:
# note these cannot use the env.Branch variables
branches: [1.4.4-modliquid, stable, preview, 1.4.4]
pull_request_target:
types: [labeled]
branches: [preview, stable, 1.4.4]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a primary job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-latest
# Make sure not to run this job on other labels
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'Safe to Test')
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out base branch
uses: actions/checkout@v2
with:
ref: ${{github.ref}}
persist-credentials: false
fetch-depth: 0
# Re-calculate the versioning of tModLoader
- name: Update Versioning
id: version
if: env.IsVersioned == 'true'
shell: bash
run: |
echo "Attempting get previous version id"
version=$(git describe --tags --abbrev=0)
echo "Previous Version is: $version"
regex="^v([0-9]+).([0-9]+).([0-9]+).([0-9]+)?$"
if [[ $version =~ $regex ]] ; then
year="${BASH_REMATCH[1]}"
month="${BASH_REMATCH[2]}"
feature="${BASH_REMATCH[3]}"
patch="${BASH_REMATCH[4]}"
oldate="$year.$month"
else
echo "Previous version '$version' is not a valid version"
exit 1
fi
echo "Checking Version Updates"
newdt="$(date +%Y.%m)"
if [[ "refs/heads/${{env.DevBranch}}" = $branch && ! "$oldate" = "$newdt" ]] ; then
echo "Checking Version Updates for ${{env.DevBranch}}"
echo "Rolling Forward the Month... from '$oldate' to '$newdt'"
oldate="$newdt"
feature=1
patch=0
elif [[ "refs/heads/${{env.StableBranch}}" = $branch && $feature = 2 || "refs/heads/${{env.PreviewBranch}}" = $branch && $feature = 1 ]] ; then
echo "Checking Version Updates for Rollover"
((++feature))
patch=0
else
echo "Rolling Forward the Patch #..."
((++patch))
fi
version="$oldate.$feature.$patch"
echo "New version is '$version'"
echo "::set-output name=new_version::$version"
env:
branch: ${{github.ref}}
# Apply new Tag for the current commit
- uses: mathieudutour/github-tag-action@v6.0
if: ${{ steps.version.outputs.new_version != null}}
with:
custom_tag: ${{ steps.version.outputs.new_version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Grab a Copy of Stable for determing what is the current stable version
- name: Check out ${{env.StableBranch}} branch
uses: actions/checkout@v2
with:
ref: "${{env.StableBranch}}"
persist-credentials: false
fetch-depth: 0
# Determine current stable version
- name: Stable Version Fetch
id: StableVer
if: github.event_name == 'push'
shell: bash
run: |
echo "Fetching the ${{env.StableBranch}} version of tmodloader"
version=$(git describe --tags --abbrev=0)
regex="^v([0-9]+).([0-9]+).([0-9]+).([0-9]+)?$"
if [[ $version =~ $regex ]] ; then
year="${BASH_REMATCH[1]}"
month="${BASH_REMATCH[2]}"
feature="${BASH_REMATCH[3]}"
patch="${BASH_REMATCH[4]}"
stableVer="$year.$month"
else
echo "Previous version '$version' is not a valid version"
exit 1
fi
echo "Stable Version is '$stableVer'"
echo "::set-output name=stable_version::$stableVer"
# Get the base branch for build steps
- name: Re:Check out base branch
uses: actions/checkout@v2
with:
ref: ${{github.ref}}
persist-credentials: false
fetch-depth: 0
- name: Check out pull request code to separate folder
uses: actions/checkout@v2
if: github.event_name == 'pull_request_target'
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
path: pullrequest
persist-credentials: false
# TODO: build doesn't have right branch I assume
- name: Copy over pull request patches folder and ExampleMod folder
if: github.event_name == 'pull_request_target'
shell: bash
run: |
ls -l
cd pullrequest
ls -l
cd ..
rm -r patches
cp -fR pullrequest/patches patches
rm -r ExampleMod
cp -fR pullrequest/ExampleMod ExampleMod
# A cache allows the build to skip the decompile step
- name: Retrieve encrypted decompiled zip cache
id: cache-decompiled
uses: actions/cache@v2
with:
path: decompiled.zip.gpg
# update key with new Terraria releases and when ilspy or ilspy decompile settings are updated
key: 1449-A
- name: Restore decompiled folder from cache
if: steps.cache-decompiled.outputs.cache-hit == 'true'
shell: bash
run: |
echo Restoring decompiled folder from cache
ls -l
gpg --quiet --batch --yes --decrypt --passphrase="$SETUP_ASSETS_PASSPHRASE" --output decompiled.zip decompiled.zip.gpg
ls -l
unzip -o decompiled.zip -d src
cd src
ls -l
cd ..
env:
SETUP_ASSETS_PASSPHRASE: ${{ secrets.SETUP_ASSETS_PASSPHRASE }}
# GitHub runners may have outdated .NET versions.
- name: Install .NET SDKs
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.406'
# Runs a set of commands using the runners shell
- name: Build script
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'Safe to Test')
shell: bash
run: |
echo CI setup for Terraria v$TERRARIA_VERSION
echo Default .NET version:
dotnet --version
echo Default .NET 'build' version:
dotnet build --version --nologo
echo Listing installed .NET SDKs:
dotnet --list-sdks
echo Listing installed .NET Runtimes:
dotnet --list-runtimes
echo Downloading Terraria Server zip
curl -s -L https://terraria.org/api/download/pc-dedicated-server/terraria-server-$TERRARIA_VERSION.zip -o terrariaserver.zip
unzip -q terrariaserver.zip
echo Extracting Setup Secret Assets
gpg --quiet --batch --yes --decrypt --passphrase="$SETUP_ASSETS_PASSPHRASE" --output ./$TERRARIA_VERSION/Windows/Terraria.exe ./setup/SecretAssets/SetupAsset1.gpg
gpg --quiet --batch --yes --decrypt --passphrase="$SETUP_ASSETS_PASSPHRASE" --output ./$TERRARIA_VERSION/Windows/SteelSeriesEngineWrapper.dll ./setup/SecretAssets/SetupAsset2.gpg
echo Installing XNA
curl -s -L https://github.com/JavidPack/tModLoaderPublishIntegration/raw/master/xnafx40_redist.msi -O
msiexec //i xnafx40_redist.msi //quiet
echo XNA Installed
echo ::group::Running setup.bat
./setup.bat auto ./$TERRARIA_VERSION/Windows
echo ::endgroup::
echo ::group::WorkspaceInfo.targets
cat src/WorkspaceInfo.targets; echo
echo ::endgroup::
echo ::group::Creating tModLoader cache zip file
7z a tModLoader.zip ./src/tModLoader/
gpg --quiet --batch --yes --symmetric --cipher-algo AES256 --passphrase="$SETUP_ASSETS_PASSPHRASE" tModLoader.zip
echo ::endgroup::
echo ::group::Giving Purpose
if [ ${{github.ref}} = 'refs/heads/${{env.StableBranch}}' ] ; then
export BUILDPURPOSE="Stable"
fi
if [ ${{github.ref}} = 'refs/heads/${{env.PreviewBranch}}' ] ; then
export BUILDPURPOSE="Preview"
fi
echo ::endgroup::
echo ::group::Building Release
dotnet clean src/tModLoader/Terraria/Terraria.csproj -c Release --nologo -v q
(
set +e;
dotnet build src/tModLoader/Terraria/Terraria.csproj -c Release --nologo -v q -bl;
err=$?;
[[ $err -ne 0 ]] && echo Uploading msbuild.binlog && curl --upload-file ./msbuild.binlog http://transfer.sh/msbuild.binlog;
exit $err
)
mkdir -p artifacts/Release
cp -r steam_build/. artifacts/Release
echo ::endgroup::
echo Cleaning up output directory in-between builds...
rm -rf steam_build
echo ::group::Building Debug
dotnet clean src/tModLoader/Terraria/Terraria.csproj -c Debug --nologo -v q
dotnet build src/tModLoader/Terraria/Terraria.csproj -c Debug --nologo -v q
mkdir -p artifacts/Debug
cp -r steam_build/. artifacts/Debug
echo ::endgroup::
echo ::group::Creating decompiled cache zip file
7z a decompiled.zip ./src/decompiled/
gpg --quiet --batch --yes --symmetric --cipher-algo AES256 --passphrase="$SETUP_ASSETS_PASSPHRASE" decompiled.zip
echo ::endgroup::
echo ::group::Creating RecentGitHubCommits.txt
git log -10 --format=oneline
git log -10 --format=oneline > artifacts/Debug/RecentGitHubCommits.txt
git log -10 --format=oneline > artifacts/Release/RecentGitHubCommits.txt
echo ::endgroup::
env:
SETUP_ASSETS_PASSPHRASE: ${{ secrets.SETUP_ASSETS_PASSPHRASE }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
TERRARIA_VERSION: 1449
TMLVERSION: ${{ steps.version.outputs.new_version }}
STABLEVERSION: ${{ steps.StableVer.outputs.stable_version }}
- name: Upload Debug Build Artifact
uses: actions/upload-artifact@v2
with:
name: Debug Build
path: |
./artifacts/Debug/
- name: Upload Release Build Artifact
uses: actions/upload-artifact@v2
with:
name: Release Build
path: |
./artifacts/Release/
- name: Upload temporary encrypted src artifact
if: env.IsVersioned == 'true'
uses: actions/upload-artifact@v2
with:
name: temporary-src
path: tModLoader.zip.gpg
#Used for CI pushes of ExampleMod. Has to utilized during the build steps
- name: Setup steamcmd
id: setupsteam
uses: CyberAndrii/setup-steamcmd@v1
- name: Build ExampleMod
shell: bash
run: |
echo ::group::Getting current published ExampleMod
publishid="2615761271"
echo "attempting download ExampleMod"
steamapps=$(pwd)/ee
steamapps=$(cygpath -w $steamapps)
${{ steps.setupsteam.outputs.executable }} +force_install_dir $steamapps +login anonymous +workshop_download_item 1281930 $publishid +quit
echo "downloaded ExampleMod"
publishedfolder=$steamapps/steamapps/workshop/content/1281930/$publishid
echo "publishedModFiles are at:"
echo $publishedfolder
if [ ! -d "$publishedfolder" ] ; then
echo "Files not Found. Steam failed to download. Try again later."
exit -12390
fi
echo ::endgroup::
echo Adding version info to ExampleMod
echo "version = ${{ steps.version.outputs.new_version }}" >> ./ExampleMod/build.txt
#pwd gives an absolute path, required for -tmlsavedirectory as the build command is executed from the steam/deployment dir
ModloaderDir=$(pwd)/local/ModLoader
echo ModloaderDir is: $ModloaderDir
mkdir -p $ModloaderDir
if [ ${{env.IsRelease}} = 'true' ] ; then
ciprep="-ciprep \"Automatic update from GitHub: ${{ github.event.compare }}\" -publishedmodfiles \"$(cygpath -w $publishedfolder)\" -uploadfolder \"/home/runner/work/tModLoader/tModLoader/artifacts/ExampleMod\""
else
ciprep=""
fi
export ExtraBuildModFlags="$ciprep -tmlsavedirectory \"$(cygpath -w $ModloaderDir)\""
echo ExtraBuildModFlags is: $ExtraBuildModFlags
echo ::group::Building ExampleMod
dotnet build ExampleMod/ExampleMod.csproj --nologo
echo ::endgroup::
mkdir -p artifacts/Mods
cp -r $ModloaderDir/Mods/. artifacts/Mods
echo ::group::Testing Example Mod build from "Mod Sources" dir
cp -r ExampleMod "$ModloaderDir/ModSources/ExampleMod"
cd "$ModloaderDir/ModSources/ExampleMod"
unset ExtraBuildModFlags
dotnet build ExampleMod.csproj --nologo
echo ::endgroup::
env:
TMLVERSION: ${{ steps.version.outputs.new_version }}
- name: Upload ExampleMod Build Artifact
uses: actions/upload-artifact@v2
with:
name: ExampleMod Build
path: |
./artifacts/Mods/
- name: List final directory and file structure
if: always()
shell: pwsh
run: tree /f /a
- name: Post push report to 1-4-nightly-builds on Discord
uses: sarisia/actions-status-discord@v1
if: always() && github.event_name == 'push'
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_BUILDBOT }}
description: |
Click [here](https://github.com/tModLoader/tModLoader/actions/runs/${{ github.run_id }}) to view.
- name: Post pull request report to 1-4-nightly-builds on Discord
uses: sarisia/actions-status-discord@v1
if: always() && github.event_name == 'pull_request_target'
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_BUILDBOT }}
color: ${{ fromJSON('{"success":1600299, "failure":8394270, "cancelled":10254856}')[job.status] }}
description: |
Pull Request: ${{github.event.pull_request.head.ref}} from ${{github.event.pull_request.head.repo.full_name}}
Click [here](https://github.com/tModLoader/tModLoader/pull/${{ github.event.number }}) to see pull request.
Click [here](https://github.com/tModLoader/tModLoader/actions/runs/${{ github.run_id }}) to view build.
documentation:
# Documentation generated on successful builds of pushes to ${{env.StableBranch}} and ${{env.PreviewBranch}}
needs: build
if: ${{ github.event_name == 'push' && (contains(github.ref, 'preview') || contains(github.ref, 'stable')) }}
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Check out base branch
uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Download temporary encrypted src artifact from build job
uses: actions/download-artifact@v2
with:
name: temporary-src
- name: Restore tModLoader folder from artifact
shell: bash
run: |
echo Restoring tModLoader folder from cache
ls -l
gpg --quiet --batch --yes --decrypt --passphrase="$SETUP_ASSETS_PASSPHRASE" --output tModLoader.zip tModLoader.zip.gpg
ls -l
unzip -o tModLoader.zip -d src
cd src
ls -l
cd ..
env:
SETUP_ASSETS_PASSPHRASE: ${{ secrets.SETUP_ASSETS_PASSPHRASE }}
- name: Update version in Doxyfile
shell: bash
run: |
echo "Attempting get current version id"
version=$(git describe --tags --abbrev=0)
echo "Current Version is: $version"
regex="^v([0-9]+).([0-9]+).([0-9]+).([0-9]+)?$"
if [[ $version =~ $regex ]] ; then
year="${BASH_REMATCH[1]}"
month="${BASH_REMATCH[2]}"
fi
version="v$year.$month"
echo "Major.Minor Version is: $version"
sed -i -e "s/TMODLOADERVERSIONHERE/$version/g" Doxyfile
working-directory: solutions/documentation
env:
branch: ${{github.ref}}
- name: Generate Documentation
uses: mattnotmitt/doxygen-action@v1.9.4
with:
working-directory: 'solutions/documentation/'
doxyfile-path: 'Doxyfile'
- name: View resulting files
run: |
echo pwd is: ${PWD}
ls -alhR
working-directory: solutions/documentation
- uses: geekyeggo/delete-artifact@v1
with:
name: temporary-src
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./solutions/documentation/html
destination_dir: ${{ fromJSON(format('{{"refs/heads/{0}":"docs/{0}","refs/heads/{1}":"docs/{1}"}}', env.StableBranch, env.PreviewBranch))[github.ref] }}
commit_message: "docs for ${{ github.ref }} commit:"
deploy:
needs: build
# We push a release only on push events to the stable/preview branch that build correctly
if: ${{ github.event_name == 'push' && (contains(github.ref, 'preview') || contains(github.ref, 'stable')) }}
name: Deploy to Steam
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Check out base branch
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Detect ExampleMod Changed Files
id: changed-files-examplemod
uses: tj-actions/changed-files@v18.4
with:
files: |
ExampleMod
- name: List all changed ExampleMod files
run: |
for file in "${{ steps.changed-files-examplemod.outputs.all_modified_files }}"; do
echo "$file was modified"
done
- name: Detect patches Changed Files
id: changed-files-patches
uses: tj-actions/changed-files@v18.4
with:
files: |
patches
- name: List all changed patches
run: |
for file in "${{ steps.changed-files-patches.outputs.all_modified_files }}"; do
echo "$file was modified"
done
- name: Download build artifact from build job
uses: actions/download-artifact@v2
with:
# Change this next line to switch between uploading Release and Debug if desired.
name: Release Build
path: artifacts/Build
- name: View build artifact files
run: |
echo pwd is: ${PWD}
ls -alhR
working-directory: artifacts/Build
# needed for publishing tML, ExampleMod
- name: Setup steamcmd
id: setupsteam
uses: CyberAndrii/setup-steamcmd@v1
# for logging in to Steam CMD
- name: Setup Authentication Files
shell: bash
run: |
echo Copying over config.vdf authentication file
echo "Steam is installed in: $STEAMCMDDIR"
echo pwd is: ${PWD}
cd ~/Steam
echo pwd is: ${PWD}
mkdir -p config
cd config
echo pwd is: ${PWD}
ls -alhR
echo Attempting to populate config.vdf
echo "$STEAM_CONFIG_VDF" | base64 -d > "config.vdf"
echo done
ls -alhR
echo Attempting to chmod config.vdf
chmod 777 "config.vdf"
echo chmod done
ls -alhR
env:
STEAM_CONFIG_VDF: ${{ secrets.STEAM_CONFIG_VDF }}
STEAMCMDDIR: ${{ steps.setupsteam.outputs.directory }}
- name: Get Version tag for Release
id: version2
shell: bash
run: |
echo "Attempting get current version id"
version=$(git describe --tags --abbrev=0)
echo "Current Version is: $version"
echo "::set-output name=new_version::$version"
env:
branch: ${{github.ref}}
# Publish new version of tModLoader to Steam
- name: Attempt run_app_build_http
shell: bash
run: |
echo "Downloading windows dotnet install zip"
dotnet_version=$(sed -n 's/^.*"version": "\(.*\)"/\1/p' <./artifacts/Build/tModLoader.runtimeconfig.json)
export dotnet_version=${dotnet_version%$'\r'}
wget https://dotnetcli.azureedge.net/dotnet/Runtime/$dotnet_version/dotnet-runtime-$dotnet_version-win-x64.zip -O ./artifacts/Build/LaunchUtils/dotnet-runtime-$dotnet_version-win-x64.zip
mkdir artifacts/shared
echo pwd is: ${PWD}
echo "Listing manifests directory"
ls -alhR ./solutions/Manifests
manifesto=${GITHUB_WORKSPACE}/solutions/Manifests
if [ ${{github.ref}} = 'refs/heads/${{env.StableBranch}}' ] ; then
manifesto=$manifesto/${{env.StableBranch}}.vdf
fi
if [ ${{github.ref}} = 'refs/heads/${{env.PreviewBranch}}' ] ; then
manifesto=$manifesto/${{env.PreviewBranch}}.vdf
sed -i -e "s/1.4.4-preview/Preview-${version:0:8}/g" $manifesto
fi
sed -i -e "s/Auto-Release/Auto-Release ($version)/g" $manifesto
steamcmd +login "${{ secrets.STEAM_USERNAME }}" +run_app_build_http $manifesto +quit
echo "Listing BuildOutput directory"
ls -alhR ./BuildOutput
echo "cat BuildOutput directory contents"
cat BuildOutput/*.log
rm ./artifacts/Build/LaunchUtils/dotnet-runtime-$dotnet_version-win-x64.zip
env:
version: ${{ steps.version2.outputs.new_version }}
- name: Download ExampleMod build artifact from build job
# This should hopefully always work since this job shouldn't even run if the build job failed due to ExampleMod not compiling.
uses: actions/download-artifact@v2
with:
name: ExampleMod Build
path: artifacts/ExampleMod
- name: View ExampleMod build artifact files
run: |
echo pwd is: ${PWD}
ls -alhR
working-directory: artifacts/ExampleMod
# Publish new version of ExampleMod using files from Build Output
- name: Attempt workshop_build_item
shell: bash
run: |
echo Changes detected in ExampleMod folder, attempting to publish ExampleMod to workshop
echo "Warning: This manual publish approach bypasses version and other checks, so updating build.txt is not necessary currently and this approach shouldn't be used by modders"
echo pwd is: ${PWD}
echo "Review Contents for publish ExampleMod"
echo publish.vdf contents:
cat publish.vdf
echo workshop.json contents:
cat Workshop/workshop.json
echo "Publishing ExampleMod"
steamcmd +login "${{ secrets.STEAM_USERNAME }}" +workshop_build_item "${PWD}/publish.vdf" +quit
echo publish.vdf contents:
cat publish.vdf
echo Done
working-directory: artifacts/ExampleMod
# Zip for making a Release Zip
- name: Install Zip
if: env.IsRelease == 'true'
uses: montudor/action-zip@v1
# Zip all files for Releases
- name: Zip Artifacts
working-directory: /home/runner/work/tModLoader/tModLoader/artifacts/
run: |
cd ExampleMod; zip -qq -r ../ExampleMod.zip .; cd ..
cd Build; zip -qq -r ../tModLoader.zip .; cd ..
# Make a Release on Github
- name: Make a release
uses: ncipollo/release-action@v1
with:
artifacts: "/home/runner/work/tModLoader/tModLoader/artifacts/ExampleMod.zip, /home/runner/work/tModLoader/tModLoader/artifacts/tModLoader.zip"
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
name: "1.4.4-${{github.ref}} Version Update: ${{ steps.version2.outputs.new_version }}"
body: "Monthly Github Auto-release for ${{github.ref}}"
tag: ${{ steps.version2.outputs.new_version }}
prerelease: ${{ contains(github.ref, 'preview') }}
makeLatest: ${{ contains(github.ref, 'stable') }}