Skip to content

v1.2.0

v1.2.0 #6

Workflow file for this run

name: Publish to NuGet
on:
release:
types: [published]
# Also allow manual trigger for testing
workflow_dispatch:
inputs:
version:
description: 'Version to publish (without v prefix, e.g., 1.0.0)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write # Required for pushing version updates
id-token: write # Required for NuGet trusted publishing (OIDC)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Extract version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
# Remove 'v' prefix from tag if present (e.g., v1.0.0 -> 1.0.0)
TAG="${{ github.event.release.tag_name }}"
VERSION="${TAG#v}"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Update Unity package version
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
# Update package.json
jq --arg v "$VERSION" '.version = $v' \
src/PhoenixSharp.Unity/Assets/Plugins/PhoenixSharp/package.json > tmp.json
mv tmp.json src/PhoenixSharp.Unity/Assets/Plugins/PhoenixSharp/package.json
# Update README.md manifest example
sed -i 's/"io.level3.phoenixsharp": "[^"]*"/"io.level3.phoenixsharp": "'"$VERSION"'"/' README.md
- name: Commit and push version update
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/PhoenixSharp.Unity/Assets/Plugins/PhoenixSharp/package.json README.md
git diff --staged --quiet || git commit -m "chore: bump version to ${{ steps.version.outputs.VERSION }}"
git push origin HEAD:master
# Re-tag to include this commit so OpenUPM sees correct version
git tag -f ${{ github.event.release.tag_name }}
git push origin ${{ github.event.release.tag_name }} --force
- name: Restore dependencies
run: dotnet restore Phoenix/Phoenix.csproj
- name: Build
run: dotnet build Phoenix/Phoenix.csproj --configuration Release --no-restore /p:Version=${{ steps.version.outputs.VERSION }}
- name: Create NuGet package
run: dotnet pack Phoenix/Phoenix.csproj --configuration Release --no-build --output ./nupkg /p:PackageVersion=${{ steps.version.outputs.VERSION }}
- name: NuGet login (OIDC trusted publishing)
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet.org
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate