Skip to content

chore(release): C#/Python 0.19.0, Java/Kotlin 7.11.0 (coordinated wit… #23

chore(release): C#/Python 0.19.0, Java/Kotlin 7.11.0 (coordinated wit…

chore(release): C#/Python 0.19.0, Java/Kotlin 7.11.0 (coordinated wit… #23

Workflow file for this run

name: publish-csharp
# Publishes the four C# packages to nuget.org via Trusted Publishing (OIDC) —
# no long-lived API key. nuget.org mints a short-lived (1 hour) key at run time
# after validating GitHub's OIDC token against the trusted-publishing policy
# configured under the `metaobjects` org. See docs/RELEASING.md.
#
# Packages: MetaObjects, MetaObjects.Render, MetaObjects.Codegen, MetaObjects.Cli (dotnet tool).
#
# One-time setup on nuget.org (your username -> Trusted Publishing -> Create):
# Package Owner: metaobjects (the org)
# Repository Owner: metaobjectsdev
# Repository: metaobjects
# Workflow File: publish-csharp.yml (filename only)
# Environment: (leave empty unless you uncomment `environment:` below)
# And add a repo secret NUGET_USER = your nuget.org *username* (profile name, NOT email).
#
# Triggers: manual (workflow_dispatch) for controlled launch, or a csharp-v* tag.
on:
workflow_dispatch:
inputs:
version:
description: "Override package version (blank = use Directory.Build.props, currently 0.11.1)"
required: false
default: ""
push:
tags:
- 'csharp-v*'
jobs:
publish:
runs-on: ubuntu-latest
# If you scope the trusted-publishing policy to a GitHub environment, create
# that environment in repo Settings and uncomment the next line (must match
# the policy's Environment field exactly):
# environment: release
permissions:
id-token: write # required: lets this job mint a GitHub OIDC token
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Pack
run: |
VERSION_ARG=""
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION_ARG="-p:Version=${{ github.event.inputs.version }}"
fi
dotnet pack server/csharp/MetaObjects/MetaObjects.csproj -c Release -o artifacts $VERSION_ARG
dotnet pack server/csharp/MetaObjects.Render/MetaObjects.Render.csproj -c Release -o artifacts $VERSION_ARG
dotnet pack server/csharp/MetaObjects.Codegen/MetaObjects.Codegen.csproj -c Release -o artifacts $VERSION_ARG
dotnet pack server/csharp/MetaObjects.Cli/MetaObjects.Cli.csproj -c Release -o artifacts $VERSION_ARG
ls -l artifacts
# OIDC -> short-lived nuget.org API key (request immediately before push; valid ~1h)
- name: NuGet login (Trusted Publishing)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: NuGet push
run: |
dotnet nuget push "artifacts/*.nupkg" \
--api-key ${{ steps.login.outputs.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate