Skip to content

Thunderstore Release #94

Thunderstore Release

Thunderstore Release #94

Workflow file for this run

name: Thunderstore Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
release_legacy_package:
description: 'Release legacy package'
required: true
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup NuGet
uses: NuGet/setup-nuget@v1
- name: Setup TCLI
run: dotnet tool install --global tcli
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build and Publish
run: |
set -x
cd BuildCI
for line in $(dotnet run --configuration Release Program.cs); do
IFS='|' read -ra parts <<< "$line"
namespace=${parts[0]}
name_underscore_separator=${parts[1]}
version=${parts[2]}
csproj_folder=${parts[3]}
nuget_package_name=${parts[4]}
cd $csproj_folder
is_project_built=false
existing_version_number=$(curl --compressed -s "https://api-v2v3search-0.nuget.org/query?q=packageid:${nuget_package_name}&prerelease=true&semVerLevel=2.0.0" | jq '.data[0]?.versions[]?.version' | grep "${version}\"" || true)
if [ -z $existing_version_number ]
then
dotnet pack --configuration Release /p:PackageOutputPath=./ReleaseOutput /p:OutputPath=./ReleaseOutput
is_project_built=true
can_nuget_push=false
if [ "$namespace" == "RiskofThunder" ]; then
nuget setapikey "${{ secrets.NUGET_API_KEY_RISK_OF_THUNDER }}"
can_nuget_push=true
else
if [ "${{ github.event.inputs.release_legacy_package }}" == 'true' ]; then
nuget setapikey "${{ secrets.NUGET_API_KEY }}"
can_nuget_push=true
fi
fi
if [ "$can_nuget_push" = true ] ; then
nuget push ./ReleaseOutput/*.nupkg -Source 'https://api.nuget.org/v3/index.json'
fi
find . -name '*.nupkg' -type f -delete
fi
existing_version_number=$(curl --compressed -s "https://thunderstore.io/api/v1/package/" | jq --arg package_name "$namespace-$name_underscore_separator" '.[]? | select(.full_name|startswith($package_name)) | .versions[0]?.version_number' | grep "${version}\"" || true)
if [ -z $existing_version_number ]
then
if [ "$is_project_built" = false ] ; then
dotnet pack --configuration Release /p:PackageOutputPath=./ReleaseOutput /p:OutputPath=./ReleaseOutput
is_project_built=true
fi
find . -name '*.pdb' -type f -delete
find . -name '*.deps.json' -type f -delete
if [ "$namespace" == "RiskofThunder" ]; then
tcli publish --token ${{ secrets.TCLI_AUTH_TOKEN_RISK_OF_THUNDER }}
else
if [ "${{ github.event.inputs.release_legacy_package }}" == 'true' ]; then
tcli publish --token ${{ secrets.TCLI_AUTH_TOKEN }}
fi
fi
rm -rf ./build
fi
if [ "$is_project_built" = true ] ; then
rm -rf ./ReleaseOutput
fi
done