From c21c032d21593288969397c4b2abd96a5f515869 Mon Sep 17 00:00:00 2001 From: phnx47-bot <78849906+phnx47-bot@users.noreply.github.com> Date: Tue, 10 Dec 2024 23:19:48 +0700 Subject: [PATCH] sync: synced file(s) with prom-client-net/prom-client-tmpl (#48) --- .github/workflows/ci-linux.yml | 91 ++++++++++++++++++++++++++++++++ .github/workflows/ci-windows.yml | 21 ++++++++ 2 files changed, 112 insertions(+) create mode 100644 .github/workflows/ci-linux.yml create mode 100644 .github/workflows/ci-windows.yml diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml new file mode 100644 index 0000000..92c7641 --- /dev/null +++ b/.github/workflows/ci-linux.yml @@ -0,0 +1,91 @@ +name: CI Linux + +on: + push: + branches: + - "main" + tags: + - "v*" + pull_request: + branches: + - "main" + workflow_dispatch: + +jobs: + build-linux: + name: Build, Test & Pack (Linux) + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + + - name: Build + run: dotnet build -c Release -p:ContinuousIntegrationBuild=true + + - name: Run tests + run: dotnet test --no-build -c Release -p:CollectCoverage=true -e:CoverletOutputFormat=opencover + + - name: Publish to Codecov + uses: codecov/codecov-action@v5 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Set Dev version + if: github.ref == 'refs/heads/main' + run: | + version="$(git describe --long --tags | sed 's/^v//;0,/-/s//./')" + if [ -z "${version}" ]; then + version="0.0.0.$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)" + fi + echo "VERSION=${version}" >> $GITHUB_ENV + + - name: Set Release version + if: startsWith(github.ref, 'refs/tags/v') + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV + + - name: Pack NuGet artifacts + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + run: dotnet pack --no-build -c Release -p:PackageVersion="${{ env.VERSION }}" + + - name: Upload artifacts + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + uses: actions/upload-artifact@v4 + with: + name: nupkgs + path: src/**/*nupkg + + github: + name: Deploy to GitHub + needs: [build-linux] + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-24.04 + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: nupkgs + - name: Push to pkg.github.com + run: dotnet nuget push "**/*.nupkg" -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -k ${{ secrets.GH_FULL_PAT }} + + nuget: + name: Deploy to NuGet + needs: [build-linux] + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-24.04 + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: nupkgs + - name: Push to nuget.org + run: dotnet nuget push "**/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_DEPLOY_KEY }} diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml new file mode 100644 index 0000000..6a7686d --- /dev/null +++ b/.github/workflows/ci-windows.yml @@ -0,0 +1,21 @@ +name: CI Windows + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + workflow_dispatch: + +jobs: + build-windows: + name: Build & Test (Windows) + runs-on: windows-2022 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run tests + run: dotnet test -c Release -p:CollectCoverage=false