Skip to content

Bump the nuget-dependencies group with 2 updates #284

Bump the nuget-dependencies group with 2 updates

Bump the nuget-dependencies group with 2 updates #284

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
types: [opened, reopened, synchronize]
workflow_call:
workflow_dispatch:
name: build-module-base
env:
DOTNET_VERSION: 10.0.x
REGISTRY: ghcr.io
jobs:
check-host-deps:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check host dependency list is in sync
run: bash scripts/sync-host-deps.sh
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.nuget/packages
key: module-base-nuget
restore-keys: |
module-base-nuget-
- name: Determine version
id: version
run: |
# Read base version from Directory.Build.props
BASE_VERSION=$(grep -oP '(?<=<Version>)[^<]+' Directory.Build.props)
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
# Tagged release: use tag as version
TAG="${GITHUB_REF#refs/tags/}"
echo "package_version=$TAG" >> "$GITHUB_OUTPUT"
echo "is_release=true" >> "$GITHUB_OUTPUT"
else
# Dev build: append pre-release suffix
echo "package_version=${BASE_VERSION}-dev.${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
echo "is_release=false" >> "$GITHUB_OUTPUT"
fi
- name: Build and Pack ModuleBase
run: dotnet build ModuleBase/ModuleBase.csproj -c Release -o ./publish/ModuleBase -p:PackageVersion=${{ steps.version.outputs.package_version }}
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: OpenShock Desktop Module Base
path: ./publish/ModuleBase/**
retention-days: 1
if-no-files-found: error
publish-github:
needs: [check-host-deps, build]
if: github.event_name == 'push'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
packages: write
steps:
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: OpenShock Desktop Module Base
path: ./packages
- name: Push to GitHub Packages
run: dotnet nuget push "./packages/*.nupkg" --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
publish-nuget:
needs: [check-host-deps, build]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
id-token: write
steps:
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: OpenShock Desktop Module Base
path: ./packages
- name: Login to NuGet.org with trusted publishing
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to NuGet.org
run: dotnet nuget push "./packages/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --skip-duplicate