FEAT: Adding event producer #10
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: build_and_run_tests | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - 'src/**' | |
| pull_request: | |
| branches: [ "main" ] | |
| paths: | |
| - 'src/**' | |
| permissions: | |
| contents: write | |
| env: | |
| VERSION_UPDATE_TYPE: "value" | |
| jobs: | |
| build-project: | |
| runs-on: ubuntu-latest | |
| name: build | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET Core @ Latest | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| env: | |
| NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Restore dependencies | |
| run: dotnet restore src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| - name: Build | |
| run: dotnet build --configuration Release src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| bump: | |
| name: Update project version | |
| runs-on: ubuntu-latest | |
| needs: [build-project] | |
| outputs: | |
| version: ${{ steps.set-version.outputs.VERSION }} | |
| version_update_type: ${{ steps.determine_update_type.outputs.VERSION_UPDATE_TYPE }} | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Determinar Tipo de Mudança | |
| id: determine_update_type | |
| run: | | |
| LAST_COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
| if echo "$LAST_COMMIT_MESSAGE" | grep -qiE "feat"; then | |
| echo "VERSION_UPDATE_TYPE=MINOR" >> $GITHUB_OUTPUT | |
| echo "VERSION_UPDATE_TYPE=MINOR" >> $GITHUB_ENV | |
| elif echo "$LAST_COMMIT_MESSAGE" | grep -qiE "fix"; then | |
| echo "VERSION_UPDATE_TYPE=REVISION" >> $GITHUB_OUTPUT | |
| echo "VERSION_UPDATE_TYPE=REVISION" >> $GITHUB_ENV | |
| else | |
| echo "VERSION_UPDATE_TYPE=NONE" >> $GITHUB_OUTPUT | |
| echo "VERSION_UPDATE_TYPE=NONE" >> $GITHUB_ENV | |
| fi | |
| - name: Print Update type | |
| run: | | |
| echo "Tipo de Mudança: ${{ steps.determine_update_type.outputs.VERSION_UPDATE_TYPE }}" | |
| - name: Bump build version - Minor | |
| if: env.VERSION_UPDATE_TYPE == 'MINOR' | |
| id: bump-minor | |
| uses: vers-one/dotnet-project-version-updater@v1.5 | |
| with: | |
| file: src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| version: "*.^.0" | |
| - name: Bump build version - Revision | |
| if: env.VERSION_UPDATE_TYPE == 'REVISION' | |
| id: bump-revision | |
| uses: vers-one/dotnet-project-version-updater@v1.5 | |
| with: | |
| file: src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| version: "*.*.^" | |
| - name: Commit and push changes - MINOR | |
| if: env.VERSION_UPDATE_TYPE == 'MINOR' | |
| run: | | |
| git config user.name "Build - Incrementing version | Github action" | |
| git config user.email "deploy@deploy.com" | |
| git add . | |
| git commit -m "CI: Updating application version ${{ steps.bump-minor.outputs.newVersion }}" | |
| git push | |
| - name: Commit and push changes - Revision | |
| if: env.VERSION_UPDATE_TYPE == 'REVISION' | |
| run: | | |
| git config user.name "Build - Incrementing version | Github action" | |
| git config user.email "deploy@deploy.com" | |
| git pull | |
| git add . | |
| git commit -m "CI: Updating application version ${{ steps.bump-revision.outputs.newVersion }}" | |
| git push | |
| - name: Set version - Revision | |
| id: set-version | |
| if: env.VERSION_UPDATE_TYPE == 'MINOR' || env.VERSION_UPDATE_TYPE == 'REVISION' | |
| run: | | |
| if [[ ${{ steps.determine_update_type.outputs.VERSION_UPDATE_TYPE }} == 'REVISION' ]]; then | |
| echo "VERSION=${{ steps.bump-revision.outputs.newVersion }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "VERSION=${{ steps.bump-minor.outputs.newVersion }}" >> $GITHUB_OUTPUT | |
| fi | |
| publish-nuGet-package: | |
| runs-on: ubuntu-latest | |
| needs: [bump] | |
| env: | |
| VERSION: ${{ needs.bump.outputs.version }} | |
| VERSION_UPDATE_TYPE: ${{ needs.bump.outputs.version_update_type }} | |
| if: github.ref == 'refs/heads/main' | |
| name: Update NuGet package | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET Core @ Latest | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| env: | |
| NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Restore dependencies | |
| run: dotnet restore src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| - name: Build solution and generate NuGet package | |
| run: | | |
| dotnet build --no-restore --configuration Release src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| dotnet pack src/AzureServiceBusFlow/AzureServiceBusFlow.csproj --no-build --configuration Release --output AzureServiceBusFlow/out | |
| - name: Push generated package to NuGet | |
| run: dotnet nuget push ./AzureServiceBusFlow/out/*.nupkg --api-key ${{ secrets.CODERAW_NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |