name: Build on: [push, pull_request] jobs: build: strategy: matrix: operating-system: ["windows", "macos", "ubuntu"] dotnet-version: ["8.0.x"] runs-on: ${{ matrix.operating-system }}-latest steps: - uses: actions/checkout@v3 - name: Setup .NET Core SDK ${{ matrix.dotnet-version }} uses: actions/setup-dotnet@v3 with: dotnet-version: ${{ matrix.dotnet-version }} - uses: actions/cache@v3 with: path: ~/.nuget/packages # Look to see if there is a cache hit for the corresponding requirements file key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: | ${{ runner.os }}-nuget - name: Install dependencies run: dotnet restore - name: Build run: dotnet build --configuration Release --no-restore - name: Test run: dotnet test --no-restore --verbosity normal publish-preview: needs: build if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} runs-on: ubuntu-latest permissions: packages: write contents: read steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup .NET Core SDK uses: actions/setup-dotnet@v3 - uses: actions/cache@v3 with: path: ~/.nuget/packages # Look to see if there is a cache hit for the corresponding requirements file key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: | ${{ runner.os }}-nuget - name: Install dependencies run: dotnet restore - name: Build the package run: dotnet build --configuration Release --no-restore -p:SymbolPackageFormat=symbols.nupkg - name: Publish the package run: dotnet nuget push src/Xdg.Directories/bin/Release/*.symbols.nupkg -s https://nuget.pkg.github.com/xdg-net/index.json -k ${{ secrets.GITHUB_TOKEN }} publish-release: needs: build if: ${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest permissions: packages: write contents: read steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup .NET Core SDK uses: actions/setup-dotnet@v3 - uses: actions/cache@v3 with: path: ~/.nuget/packages # Look to see if there is a cache hit for the corresponding requirements file key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} restore-keys: | ${{ runner.os }}-nuget - name: Install dependencies run: dotnet restore - name: Build the package run: dotnet build --configuration Release --no-restore -p:SymbolPackageFormat=snupkg - name: Publish the package run: | dotnet nuget push src/Xdg.Directories/bin/Release/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_KEY }} env: NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }}