From 17c9bf251015773f57a7f0611c9bc905fefe0216 Mon Sep 17 00:00:00 2001 From: f1x3d <17356460+f1x3d@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:21:55 +0300 Subject: [PATCH] Add the CI pipeline (#4) --- .github/workflows/ci.yaml | 97 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..302df52 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,97 @@ +name: CI + +on: + push: + branches: [ 'main' ] + pull_request: + branches: [ '*' ] + release: + types: [ 'released' ] + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_NOLOGO: true + DOTNET_VERSION: 6.x + DOTNET_QUALITY: ga + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + dotnet-quality: ${{ env.DOTNET_QUALITY }} + + - name: Restore dependencies + run: dotnet restore *.sln + + - name: Build project + run: dotnet build *.sln --no-restore -c Release + + - name: Pack + run: dotnet pack *.sln --no-build -c Release + + - name: Publish build artifacts + uses: actions/upload-artifact@v3 + with: + name: build + path: ${{ github.workspace }} + if-no-files-found: error + + # test: + # name: Test + # needs: [ build ] + # runs-on: ubuntu-latest + # steps: + # - name: Download build artifacts + # uses: actions/download-artifact@v3 + # with: + # name: build + # path: ${{ github.workspace }} + + # - name: Run tests + # run: dotnet test *.sln --no-build -c Release + + publish: + name: Publish + if: github.event_name == 'release' + # needs: [ test ] + needs: [ build ] + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build + path: ${{ github.workspace }} + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + dotnet-quality: ${{ env.DOTNET_QUALITY }} + + - name: Publish to NuGet.org + run: dotnet nuget push **/*.nupkg -k $NUGET_API_KEY -s https://api.nuget.org/v3/index.json --skip-duplicate + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + + - name: Add the GitHub Packages source + run: dotnet nuget add source --username $GITHUB_USERNAME --password $GITHUB_TOKEN --store-password-in-clear-text --name github "$FEED_SOURCE" + env: + GITHUB_USERNAME: ${{ github.repository_owner }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FEED_SOURCE: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + + - name: Publish to GitHub Packages + run: dotnet nuget push **/*.nupkg -k $GITHUB_TOKEN -s "github" --skip-duplicate + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}