From f06155003240d450a997a4acf462f17dd7d6011c Mon Sep 17 00:00:00 2001 From: ihourglass Date: Fri, 11 Oct 2024 01:56:16 +0800 Subject: [PATCH] Add github action files. --- .github/workflows/publish-prerelease.yml | 38 ++++++++++++++++++++ .github/workflows/publish-release-tag.yml | 42 +++++++++++++++++++++++ .github/workflows/test.yml | 32 +++++++++++++++++ 3 files changed, 112 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..922a0ce --- /dev/null +++ b/.github/workflows/publish-prerelease.yml @@ -0,0 +1,38 @@ +name: Publish Prerelease NuGets +on: + push: + branches: + - prerelease +env: + TIMESTAMP: $(date +'%s') + SOLUTION: Pooling.sln +jobs: + publish: + name: Build and Publish + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: 8.0.x + + - name: Remove Samples + run: dotnet sln ${{ env.SOLUTION }} remove $(find samples -name "*.csproj") + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution + run: dotnet build --configuration Release --no-restore ${{ env.SOLUTION }} --version-suffix preview-${{ 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 preview-${{ 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..4ec3a19 --- /dev/null +++ b/.github/workflows/publish-release-tag.yml @@ -0,0 +1,42 @@ +name: Publish Release NuGets on tag +on: + push: + tags: + - '*' +env: + SOLUTION: Pooling.sln +jobs: + publish: + name: Build and Publish + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: 8.0.x + + - name: Remove Samples + run: dotnet sln ${{ env.SOLUTION }} remove $(find samples -name "*.csproj") + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution + run: dotnet build --configuration Release --no-restore ${{ 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..794616e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Test +on: + push: + branches: + - master + paths: + - 'src/**' + - 'test/**' + - '.github/workflows/**' +env: + SOLUTION: Fody.Cli.sln +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: 8.0.x + + - name: Remove Samples + run: dotnet sln ${{ env.SOLUTION }} remove $(find samples -name "*.csproj") + + - name: Restore NuGets + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build Solution in RELEASE + run: dotnet build --configuration Release --no-restore ${{ env.SOLUTION }}