From dedb3c7832e7474e4a8057dc4da7d785edc4e45c Mon Sep 17 00:00:00 2001 From: sagilio Date: Wed, 26 Jul 2023 03:28:16 +0800 Subject: [PATCH] ci: Split push package from release and fix execute error Signed-off-by: sagilio --- .github/workflows/push.yml | 86 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 81 --------------------------------- Casbin.NET.sln | 1 + 3 files changed, 87 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..428659a --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,86 @@ +name: Release + +on: workflow_dispatch + +env: + SHA: ${{ GITHUB.SHA }} + REF: ${{ GITHUB.REF }} + RUN_ID: ${{ GITHUB.RUN_ID }} + RUN_NUMBER: ${{ GITHUB.RUN_NUMBER }} + BUILD_RUN_NUMBER: build.${{ GITHUB.RUN_NUMBER }} + GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }} + MYGET_API_TOKEN: ${{ SECRETS.MYGET_API_TOKEN }} + NUGET_API_TOKEN: ${{ SECRETS.NUGET_API_KEY }} + COVERALLS_REPO_TOKEN: ${{ SECRETS.COVERALLS_REPO_TOKEN }} + +jobs: + push-packages: + runs-on: windows-latest + needs: run-semantic-release + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Git fetch tags + run: git fetch --tags + + - name: Check tags + run: git tag -l -n + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + include-prerelease: true + + - name: Check .NET info + run: dotnet --info + + - name: Install dependencies + run: dotnet restore + + - name: Build solution + run: dotnet build -c Release --no-restore + + - name: Pack packages + run: | + $LastTag = git describe --tags (git rev-list --tags --max-count=1); + echo "Last tag is: $LastTag"; + $Version = ($LastTag).TrimStart('v'); + echo "Publishing version: $Version"; + dotnet pack -c Release -o packages /p:PackageVersion=$Version /p:Version=$Version; + + if($LastExitCode -ne 0) + { + Write-Warning -Message "Pack packages warming, last exit code is ${LastExitCode}." + $LastExitCode = 0; + } + + - name: Upload packages artefacts + uses: actions/upload-artifact@v1.0.0 + with: + name: "drop-ci-packages" + path: './packages' + + - name: Add myget nuget source + run: dotnet nuget add source https://www.myget.org/F/casbin-net/api/v2/package --name myget.org + + - name: Push packages to myget.org + run: dotnet nuget push .\packages\*.nupkg -s myget.org -k $env:MYGET_API_TOKEN --skip-duplicate + + - name: Add github nuget source + run: dotnet nuget add source https://nuget.pkg.github.com/casbin/index.json --name github.com --username casbin --password $env:GITHUB_TOKEN + + - name: Push packages to github.com + run: dotnet nuget push .\packages\*.nupkg -s github.com --skip-duplicate; + + - name: Push packages to nuget.org + run: dotnet nuget push .\packages\*.nupkg -s nuget.org -k $env:NUGET_API_TOKEN --skip-duplicate diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc06e79..f3212fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,84 +87,3 @@ jobs: export PATH=$PATH:$(yarn global bin) yarn global add semantic-release@17.4.3 semantic-release - - release: - runs-on: windows-latest - needs: run-semantic-release - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Git fetch tags - run: git fetch --tags - - - name: Check tags - run: git tag -l -n - - - name: Setup .NET Core 3.1.x SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.x - - - name: Setup .NET 5.0.x SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.x - - - name: Setup .NET 6.0.x SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - - name: Setup .NET 7.0.x SDK - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 7.0.x - include-prerelease: true - - - name: Check .NET info - run: dotnet --info - - - name: Install dependencies - run: dotnet restore - - - name: Build solution - run: dotnet build -c Release --no-restore - - - name: Pack packages - run: | - $LastTag = git describe --tags (git rev-list --tags --max-count=1); - echo "Last tag is: $LastTag"; - $Version = ($LastTag).TrimStart('v'); - echo "Publishing version: $Version"; - dotnet pack -c Release -o packages /p:PackageVersion=$Version /p:Version=$Version; - - if($LastExitCode -ne 0) - { - Write-Warning -Message "Pack packages warming, last exit code is ${LastExitCode}." - $LastExitCode = 0; - } - - - name: Upload packages artefacts - uses: actions/upload-artifact@v1.0.0 - with: - name: "drop-ci-packages" - path: './packages' - - - name: Add myget nuget source - run: dotnet nuget add source https://www.myget.org/F/casbin-net/api/v2/package --name myget.org - - - name: Push packages to myget.org - run: dotnet nuget push .\packages\*.nupkg -s myget.org -k $env:MYGET_API_TOKEN --skip-duplicate - - - name: Add github nuget source - run: dotnet nuget add source https://nuget.pkg.github.com/casbin/index.json --name github.com --username casbin --password $env:GITHUB_TOKEN - - - name: Push packages to github.com - run: dotnet nuget push .\packages\*.nupkg -s github.com --skip-duplicate; - - - name: Push packages to nuget.org - run: dotnet nuget push .\packages\*.nupkg -s nuget.org -k $env:NUGET_API_TOKEN --skip-duplicate diff --git a/Casbin.NET.sln b/Casbin.NET.sln index 500a887..b2245c9 100644 --- a/Casbin.NET.sln +++ b/Casbin.NET.sln @@ -20,6 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md .github\workflows\release.yml = .github\workflows\release.yml global.json = global.json + .github\workflows\push.yml = .github\workflows\push.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Casbin.Benchmark", "Casbin.Benchmark\Casbin.Benchmark.csproj", "{1DBC2931-4981-4DB5-A30B-FF6EB8622B04}"