Skip to content

Publish Release

Publish Release #48

name: Publish Release
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
env:
NEBULA_FOLDER : dist\\release\\nebula\\
DIST_RELEASE_FOLDER : dist\\release\\
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0 # can't shallowly clone due to git versioning
- run: |
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor }}@users.noreply.github.com'
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "14"
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Clear output directory in DSP files
# We use SilentlyContinue here because it errors out if the folder does not exist otherwise
run : rm -R -ErrorAction SilentlyContinue "dist"
- name: Add remote build identifier
run: New-Item -Name .remoteBuild -ItemType File -force
# Add dotnet to the PATH: https://github.com/actions/setup-dotnet
- name: Setup dotnet.exe
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
# Build it
- name: Build the application
run: dotnet build -c Release /p:PublicRelease=true
# Bundle
- name: Bundle build for thunderstore and github
env:
TCLI_AUTH_TOKEN: ${{ secrets.TS_SERVICE_ACCOUNT_TOKEN }}
run: node .github\scripts\thunderstore_bundle.js
# Upload the thunderstore artifact (in case automatic upload fails)
- uses: actions/upload-artifact@v4
with:
name: nebula-thunderstore
path: ${{ env.DIST_RELEASE_FOLDER }}nebula-NebulaMultiplayerMod
# Upload the API thunderstore artifact (in case automatic upload fails)
- uses: actions/upload-artifact@v4
with:
name: nebula-api-thunderstore
path: ${{ env.DIST_RELEASE_FOLDER }}nebula-NebulaMultiplayerModApi
continue-on-error: true
# Get Version
- id: getver
run: |
$ver = (Get-Content version.json | ConvertFrom-Json).version
echo "::set-output name=ver::$ver"
# Create release
- uses: NebulaModTeam/release-action@v1
with:
artifactErrorsFailBuild: true
bodyFile: "${{ env.DIST_RELEASE_FOLDER }}BODY.md"
artifacts: "${{ env.DIST_RELEASE_FOLDER }}Nebula_${{ steps.getver.outputs.ver }}.zip"
tag: v${{ steps.getver.outputs.ver }}
commit: ${{ github.event.base_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
# Publish to NuGet
- name: Publish to NuGet
run: |
dotnet pack .\NebulaAPI\NebulaAPI.csproj -c Release -o "." -p:OutDir="bin/net472/Release/" -p:PublicRelease=true
dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate