Generate SDKs #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)" | |
| env: | |
| COMMIT_REASON: ${{ github.event.inputs.commit_reason && format('({0})', github.event.inputs.commit_reason) || '' }} | |
| 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=. | |
| - 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 |