Move code #4
Workflow file for this run
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 - Build, Test, and Publish SDKs | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| version-number: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set current date in UTC as env variable | |
| run: | | |
| export CURRENT_DATE="$(date -u +'%Y.%m.%d')" | |
| echo "Current date is ${CURRENT_DATE}" | |
| echo "CURRENT_DATE=${CURRENT_DATE}" >> $GITHUB_ENV | |
| - id: build_version | |
| name: Generate Build Version | |
| run: | | |
| export BUILD_VERSION="$CURRENT_DATE.${{ github.run_number }}" | |
| echo "Build version is ${BUILD_VERSION}" | |
| echo "BUILD_VERSION=${BUILD_VERSION}" >> $GITHUB_OUTPUT | |
| - id: package_version | |
| name: Generate Package Version | |
| run: | | |
| export PACKAGE_VERSION="$CURRENT_DATE-preview.${{ github.run_number }}" | |
| echo "Package version is ${PACKAGE_VERSION}" | |
| echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT | |
| outputs: | |
| BUILD_VERSION: ${{ steps.build_version.outputs.BUILD_VERSION }} | |
| PACKAGE_VERSION: ${{ steps.package_version.outputs.PACKAGE_VERSION }} | |
| changed-sdks: | |
| name: Determine Changed SDKs | |
| runs-on: ubuntu-latest | |
| outputs: | |
| dotnet-sdk: ${{ steps.check_dotnet_sdk.outputs.changed }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - id: git_refs | |
| name: Set Git refs for diff | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| echo "base=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT" | |
| echo "head=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "base=${{ github.event.before }}" >> "$GITHUB_OUTPUT" | |
| echo "head=${{ github.sha }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - id: check_dotnet_sdk | |
| name: Check .NET SDK changes | |
| run: | | |
| if git diff --name-only "${{ steps.git_refs.outputs.base }}" "${{ steps.git_refs.outputs.head }}" -- 'dotnet/**' | grep -q .; then | |
| echo ".NET SDK changes detected" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No .NET SDK changes detected" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| dotnet-sdk: | |
| name: .NET SDK | |
| needs: [version-number, changed-sdks] | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./dotnet/sdk | |
| strategy: | |
| matrix: | |
| dotnet-version: ['8.0.x'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # - name: Setup .NET ${{ matrix.dotnet-version }} | |
| # uses: actions/setup-dotnet@v4 | |
| # with: | |
| # dotnet-version: ${{ matrix.dotnet-version }} | |
| # source-url: https://pkgs.dev.azure.com/msazure/OneAgile/_packaging/Agent365/nuget/v3/index.json | |
| # env: | |
| # NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_TOKEN }} | |
| - name: Restore dependencies | |
| run: dotnet restore Microsoft.Kairo.Sdk.sln | |
| - name: Build solution | |
| run: dotnet build Microsoft.Kairo.Sdk.sln --no-restore --configuration Release /p:Version=${{ needs.version-number.outputs.BUILD_VERSION }} | |
| - name: Run tests | |
| run: dotnet test Microsoft.Kairo.Sdk.sln --no-build --configuration Release --verbosity normal | |
| - name: Pack NuGet packages | |
| run: dotnet pack Microsoft.Kairo.Sdk.sln --no-build --configuration Release --output ../NuGetPackages /p:PackageVersion=${{ needs.version-number.outputs.PACKAGE_VERSION }} |