Skip to content

Package NuGet

Package NuGet #16

Workflow file for this run

name: Package NuGet
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
nugetPackageVersion:
description: "NuGet package version"
required: true
shouldCreateTag:
description: "Create a git tag + Release?"
required: true
type: boolean
default: true
permissions:
contents: write # "write" needed for the "Tag a release" step.
jobs:
compile-sdl2cs:
name: Build SDL2-CS
uses: ./.github/workflows/build-sdl2cs.yml
compile-natives:
name: Build native dependencies
uses: ./.github/workflows/build-natives.yml
package-nuget:
name: Package NuGet
runs-on: ubuntu-22.04
needs: [compile-sdl2cs, compile-natives]
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Prepare environment variables
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "PACKAGE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "SHOULD_TAG_RELEASE=true" >> $GITHUB_ENV
else
echo "PACKAGE_VERSION=${{ github.event.inputs.nugetPackageVersion }}" >> $GITHUB_ENV
echo "SHOULD_TAG_RELEASE=${{ github.event.inputs.shouldCreateTag }}" >> $GITHUB_ENV
fi
- name: Download artifacts - SDL2-CS.dll
uses: actions/download-artifact@v4
with:
name: SDL2-CS
path: ./bin
- name: Download artifacts - native - Windows
uses: actions/download-artifact@v4
with:
name: Natives-Windows
path: ./native/win
- name: Download artifacts - native - MacOS
uses: actions/download-artifact@v4
with:
name: Natives-MacOS
path: ./native/osx
- name: Download artifacts - native - Linux (x64)
uses: actions/download-artifact@v4
with:
name: Natives-Linux(x64)
path: ./native/linux
- name: Download artifacts - native - Linux (arm64)
uses: actions/download-artifact@v4
with:
name: Natives-Linux(arm64)
path: ./native/linux
- name: Setup NuGet.exe
uses: NuGet/setup-nuget@v1
- name: Package NuGet
run: |
nuget pack OpenRA-SDL2-CS.nuspec -OutputDirectory ./nuget -version ${{ env.PACKAGE_VERSION }}
- name: Upload NuGet package to Artifacts
uses: actions/upload-artifact@v4
with:
name: NuGet Package ${{ env.PACKAGE_VERSION }}
path: ./nuget
- name: Tag a release
if: ${{ env.SHOULD_TAG_RELEASE == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.PACKAGE_VERSION }}
overwrite: true
file_glob: true
file: ./nuget/*.nupkg
- name: Publish package to NuGet
if: ${{ env.SHOULD_TAG_RELEASE == 'true' }}
run: |
nuget push ./nuget/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_KEY }}