From 995b304479d40e97604b146316e30b2da3fea0ad Mon Sep 17 00:00:00 2001 From: ihourglass Date: Tue, 13 Aug 2024 13:29:47 +0800 Subject: [PATCH] Add github action files. --- .github/workflows/publish-prerelease.yml | 43 +++++++++++ .github/workflows/publish-release-tag.yml | 49 +++++++++++++ .github/workflows/test.yml | 87 +++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 .github/workflows/publish-prerelease.yml create mode 100644 .github/workflows/publish-release-tag.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml new file mode 100644 index 0000000..06fdf1a --- /dev/null +++ b/.github/workflows/publish-prerelease.yml @@ -0,0 +1,43 @@ +name: Publish Prerelease NuGets +on: + push: + branches: + - prerelease +env: + TIMESTAMP: $(date +'%s') + SOLUTION: Rougamo.Retry.sln +jobs: + publish: + name: Build and Publish + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + + - name: Remove Tests + run: dotnet sln ${{ env.SOLUTION }} remove (ls -r test/**/*.csproj) + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution + run: dotnet build --configuration Release --no-restore ${{ env.SOLUTION }} --version-suffix priview-${{ env.TIMESTAMP }} + + - name: Delete exists packages + run: rm -r -fo nugets + + - name: Pack Solution + run: dotnet pack ${{ env.SOLUTION }} --configuration Release --no-build --version-suffix priview-${{ env.TIMESTAMP }} + + - name: Publish + run: dotnet nuget push nugets/**.nupkg -k ${{ secrets.API_KEY }} -s https://api.nuget.org/v3/index.json diff --git a/.github/workflows/publish-release-tag.yml b/.github/workflows/publish-release-tag.yml new file mode 100644 index 0000000..03ef9b2 --- /dev/null +++ b/.github/workflows/publish-release-tag.yml @@ -0,0 +1,49 @@ +name: Publish Release NuGets on tag +on: + push: + tags: + - '*' +env: + SOLUTION: Rougamo.Retry.sln +jobs: + publish: + name: Build and Publish + runs-on: windows-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution + run: dotnet build --configuration Release --no-restore ${{ env.SOLUTION }} + + - name: Run Tests + run: dotnet test --configuration Release --no-build ${{ env.SOLUTION }} + + - name: Delete exists packages + run: rm -r -fo nugets + + - name: Pack NuGets + run: dotnet pack ${{ env.SOLUTION }} --no-build --configuration Release + + - name: Publish + run: dotnet nuget push nugets/**.nupkg -k ${{ secrets.API_KEY }} -s https://api.nuget.org/v3/index.json + + - name: Create github release + uses: ncipollo/release-action@v1 + with: + bodyFile: CHANGELOG.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8d3cc19 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,87 @@ +name: Test +on: + push: + branches: + - master + paths: + - 'src/**' + - 'test/**' + - '.github/workflows/**' +env: + SOLUTION: Rougamo.Retry.sln +jobs: + windows: + name: Windows + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution in DEBUG + run: dotnet build --configuration Debug --no-restore ${{ env.SOLUTION }} + + - name: Test in DEBUG + run: dotnet test --configuration Debug --no-build ${{ env.SOLUTION }} + + - name: Build Solution in RELEASE + run: dotnet build --configuration Release --no-restore ${{ env.SOLUTION }} + + - name: Test in RELEASE + run: dotnet test --configuration Release --no-build ${{ env.SOLUTION }} + + linux: + name: Linux + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution in DEBUG + run: dotnet build --configuration Debug --no-restore ${{ env.SOLUTION }} + + - name: Test in DEBUG with netcoreapp3.1 + run: dotnet test --configuration Debug --no-build --framework netcoreapp3.1 ${{ env.SOLUTION }} + + - name: Test in DEBUG with net6.0 + run: dotnet test --configuration Debug --no-build --framework net6.0 ${{ env.SOLUTION }} + + - name: Test in DEBUG with net8.0 + run: dotnet test --configuration Debug --no-build --framework net8.0 ${{ env.SOLUTION }} + + - name: Build Solution in RELEASE + run: dotnet build --configuration Release --no-restore ${{ env.SOLUTION }} + + - name: Test in RELEASE with netcoreapp3.1 + run: dotnet test --configuration Release --no-build --framework netcoreapp3.1 ${{ env.SOLUTION }} + + - name: Test in RELEASE with net6.0 + run: dotnet test --configuration Release --no-build --framework net6.0 ${{ env.SOLUTION }} + + - name: Test in RELEASE with net8.0 + run: dotnet test --configuration Release --no-build --framework net8.0 ${{ env.SOLUTION }}