diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml new file mode 100644 index 00000000..c26b0650 --- /dev/null +++ b/.github/workflows/release-package.yml @@ -0,0 +1,58 @@ +name: Release solution + +on: + workflow_dispatch: + push: + # paths: ['src/**', '.github/workflows/**', 'msgraph-cli-core.sln'] + +jobs: + build: + runs-on: ubuntu-latest + env: + MS_NUGET_URL: https://nuget.pkg.github.com/microsoft/index.json + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup .NET Core SDK 6 + uses: actions/setup-dotnet@v3.2.0 + with: + dotnet-version: 7.x + - 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: Test + run: dotnet test --no-restore + - id: publish + name: Publish + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + run: dotnet publish --no-restore --verbosity normal -c Release + - id: pack + name: Pack + if: ${{ steps.publish.outcome == 'success' }} + run: dotnet pack --no-restore --no-build --verbosity normal -c Release + - name: Upload Nuget Package + if: ${{ steps.pack.outcome == 'success' }} + uses: actions/upload-artifact@v3 + with: + name: drop + path: | + ./src/Microsoft.Graph.Cli.Core/bin/Release/*.nupkg + deploy: + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v3.2.0 + with: + dotnet-version: 7.x + - uses: actions/download-artifact@v3 + with: + name: drop + - run: dotnet nuget push "*.nupkg" --skip-duplicate -s https://nuget.pkg.github.com/microsoftgraph/index.json -k ${{ secrets.GITHUB_TOKEN }}