FEAT: Adding new changes #38
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: | |
| - "**" # qualquer branch | |
| paths: | |
| - "src/**" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-project: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - run: dotnet restore src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| - run: dotnet build --configuration Release src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| bump: | |
| runs-on: ubuntu-latest | |
| needs: build-project | |
| outputs: | |
| version: ${{ steps.set-version.outputs.VERSION }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Detect branch | |
| id: branch | |
| run: | | |
| BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
| echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
| if [[ "$BRANCH_NAME" == "main" ]]; then | |
| echo "IS_MAIN=true" >> $GITHUB_ENV | |
| else | |
| echo "IS_MAIN=false" >> $GITHUB_ENV | |
| fi | |
| - name: Bump official version | |
| if: env.IS_MAIN == 'true' | |
| id: bump-main | |
| uses: vers-one/dotnet-project-version-updater@v1.5 | |
| with: | |
| file: src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| version: "*.^.0" | |
| - name: Bump beta version | |
| if: env.IS_MAIN == 'false' | |
| id: bump-beta | |
| run: | | |
| BASE_VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" src/AzureServiceBusFlow/AzureServiceBusFlow.csproj || echo "1.0.0") | |
| BETA_VERSION="${BASE_VERSION}-beta.${{ github.run_number }}" | |
| echo "Atualizando versão para $BETA_VERSION" | |
| sed -i "s|<Version>.*</Version>|<Version>$BETA_VERSION</Version>|" src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| echo "VERSION=$BETA_VERSION" >> $GITHUB_OUTPUT | |
| - name: Commit and push version | |
| run: | | |
| git config user.name "Build - Incrementing version | Github action" | |
| git config user.email "deploy@deploy.com" | |
| git add src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| git commit -m "CI: Updating application version" | |
| git push | |
| - name: Set version output | |
| id: set-version | |
| run: | | |
| if [[ "${{ env.IS_MAIN }}" == "true" ]]; then | |
| echo "VERSION=${{ steps.bump-main.outputs.newVersion }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "VERSION=${{ steps.bump-beta.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| fi | |
| publish-nuGet-package: | |
| runs-on: ubuntu-latest | |
| needs: bump | |
| env: | |
| VERSION: ${{ needs.bump.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - run: dotnet restore src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| - run: | | |
| dotnet build --no-restore --configuration Release src/AzureServiceBusFlow/AzureServiceBusFlow.csproj | |
| dotnet pack src/AzureServiceBusFlow/AzureServiceBusFlow.csproj --no-build --configuration Release --output out | |
| - run: | | |
| echo "Publicando versão $VERSION" | |
| dotnet nuget push ./out/*.nupkg --api-key ${{ secrets.CODERAW_NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json |