Skip to content

Generate SDKs

Generate SDKs #10

Workflow file for this run

name: Generate SDKs
on:
workflow_dispatch:
inputs:
commit_reason:
description: "Commit Reason"
required: false
dry_run:
type: boolean
default: false
description: "Dry run (Do not commit)"
build_offset:
description: "Number to add to the version number"
required: false
env:
COMMIT_REASON: ${{ github.event.inputs.commit_reason && format('({0})', github.event.inputs.commit_reason) || '' }}
BUILD_OFFSET: ${{ github.event.inputs.build_offset }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
- name: πŸ›  Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: πŸš€ Run SDK Generator
run: dotnet run --project ./CommunityFabs.NET.Generator/CommunityFabs.NET.Generator.csproj --out=. --offset=${BUILD_OFFSET}
- name: πŸ•΅οΈ Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> "$GITHUB_OUTPUT"
else
echo "changes=false" >> "$GITHUB_OUTPUT"
fi
- name: 🧾 Create local nuget.config
if: steps.check_changes.outputs.changes == 'true'
run: |
echo '<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="local" value="nupkgs" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>' > nuget.config
- name: βœ… Validate CommunityFabs.NET.Common
if: steps.check_changes.outputs.changes == 'true'
run: |
dotnet pack ./CommunityFabs.NET.Common/CommunityFabs.NET.Common.csproj -c Release -o ./nupkgs
- name: βœ… Validate CommunityFabs.NET.Instance
if: steps.check_changes.outputs.changes == 'true'
run: |
dotnet restore ./CommunityFabs.NET.Instance/CommunityFabs.NET.Instance.csproj --configfile nuget.config
dotnet pack ./CommunityFabs.NET.Instance/CommunityFabs.NET.Instance.csproj -c Release -o ./nupkgs
- name: βœ… Validate CommunityFabs.NET.Functions
if: steps.check_changes.outputs.changes == 'true'
run: |
dotnet restore ./CommunityFabs.NET.Functions/CommunityFabs.NET.Functions.csproj --configfile nuget.config
dotnet pack ./CommunityFabs.NET.Functions/CommunityFabs.NET.Functions.csproj -c Release -o ./nupkgs
- name: πŸ“ Show changed files (dry run)
if: steps.check_changes.outputs.changes == 'true' && github.event.inputs.dry_run == 'true'
run: |
echo "Dry run enabled. The following files were changed:"
git status --short
- name: πŸ“€ Commit and push SDK changes
if: steps.check_changes.outputs.changes == 'true' && github.event.inputs.dry_run != 'true'
run: |
git config user.name "GitHub Actions Bot"
git config user.email "action@github.com"
git add .
git commit -m "chore: generate SDKs ${COMMIT_REASON}"
git push origin HEAD