Merge pull request #19 from MAES-Software/mer_implementacija #32
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: CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| name: Build and test | |
| runs-on: ubuntu-latest | |
| env: | |
| SUPER_BUSINESS_GUID: ${{ secrets.SUPER_BUSINESS_GUID }} | |
| SUPER_USERNAME: ${{ secrets.SUPER_USERNAME }} | |
| SUPER_PASSWORD: ${{ secrets.SUPER_PASSWORD }} | |
| EPOSLOVANJE_USERNAME: ${{ secrets.EPOSLOVANJE_USERNAME }} | |
| EPOSLOVANJE_PASSWORD: ${{ secrets.EPOSLOVANJE_PASSWORD }} | |
| EPOSLOVANJE_API_KEY: ${{ secrets.EPOSLOVANJE_API_KEY }} | |
| DOKU_API_KEY: ${{ secrets.DOKU_API_KEY }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore MAES.Fiskal2.Tests/MAES.Fiskal2.Tests.csproj | |
| - name: Run tests | |
| run: dotnet test MAES.Fiskal2.Tests/MAES.Fiskal2.Tests.csproj --configuration Release --no-restore -v normal --logger "console;verbosity=detailed" | |
| pack-and-publish: | |
| name: Pack and publish package | |
| needs: test | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore MAES.Fiskal2/MAES.Fiskal2.csproj | |
| - name: Build library | |
| run: dotnet build MAES.Fiskal2/MAES.Fiskal2.csproj --configuration Release --no-restore | |
| - name: Determine package version | |
| id: version | |
| run: | | |
| VERSION_PREFIX=$(grep -oPm1 "(?<=<Version>)[^<]+" MAES.Fiskal2/MAES.Fiskal2.csproj) | |
| PACKAGE_VERSION="${VERSION_PREFIX%.*}.${GITHUB_RUN_NUMBER}" | |
| echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV | |
| echo "Pack version: $PACKAGE_VERSION" | |
| - name: Pack library | |
| # Use existing build outputs; avoid rebuilding here | |
| run: dotnet pack MAES.Fiskal2/MAES.Fiskal2.csproj --configuration Release --output ./artifacts --no-restore --no-build /p:PackageVersion=${{ env.PACKAGE_VERSION }} | |
| - name: Publish package to NuGet | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }} | |
| run: | | |
| dotnet nuget push "./artifacts/*.nupkg" \ | |
| --api-key "$NUGET_API_KEY" \ | |
| --source https://api.nuget.org/v3/index.json \ | |
| --skip-duplicate |