From 20d8cb1e8417311874002659bf9df9ae4929a076 Mon Sep 17 00:00:00 2001 From: Yaohui Liu Date: Wed, 25 Oct 2023 00:44:44 +0800 Subject: [PATCH 1/2] ci: try to fix error of pushing package. --- .github/workflows/release-minor-trigger.yml | 19 +++++++ ...{release_prepare.yml => release-minor.yml} | 31 +++++------- .github/workflows/release-patch-trigger.yml | 19 +++++++ .github/workflows/release-patch.yml | 50 +++++++++++++++++++ .github/workflows/release.yml | 28 ----------- 5 files changed, 101 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/release-minor-trigger.yml rename .github/workflows/{release_prepare.yml => release-minor.yml} (57%) create mode 100644 .github/workflows/release-patch-trigger.yml create mode 100644 .github/workflows/release-patch.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release-minor-trigger.yml b/.github/workflows/release-minor-trigger.yml new file mode 100644 index 000000000..f9b3452c2 --- /dev/null +++ b/.github/workflows/release-minor-trigger.yml @@ -0,0 +1,19 @@ +name: release-minor-trigger + +on: + pull_request: + branches: + - master + types: [ closed ] + +jobs: + trigger_minor_release: + if: contains(github.event.pull_request.labels.*.name, 'minor-release') && !contains(github.event.pull_request.labels.*.name, 'patch-release') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET 6.0.x SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x \ No newline at end of file diff --git a/.github/workflows/release_prepare.yml b/.github/workflows/release-minor.yml similarity index 57% rename from .github/workflows/release_prepare.yml rename to .github/workflows/release-minor.yml index 3f5bb66ed..11693ac8e 100644 --- a/.github/workflows/release_prepare.yml +++ b/.github/workflows/release-minor.yml @@ -1,27 +1,19 @@ -name: release-prepare +name: auto-release on: - pull_request: - branches: - - master - types: [ closed ] + workflow_run: + workflows: ["release-minor-trigger"] + types: + - completed env: - IS_MINOR: ${{contains(github.event.pull_request.labels.*.name, 'minor-release')}} - IS_PATCH: ${{contains(github.event.pull_request.labels.*.name, 'patch-release')}} + NUGET_API_TOKEN: ${{ secrets.LLAMA_SHARP_NUGET_KEY }} jobs: - prepare_package: - if: contains(github.event.pull_request.labels.*.name, 'minor-release') || contains(github.event.pull_request.labels.*.name, 'patch-release') + minor_release_to_nuget: runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Setup .NET 6.0.x SDK - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 6.0.x + steps: - name: Setup NuGet uses: nuget/setup-nuget@v1 with: @@ -46,10 +38,13 @@ jobs: git fetch origin; chmod +x ./.github/prepare_release.sh - ./.github/prepare_release.sh $IS_MINOR $IS_PATCH + ./.github/prepare_release.sh true false - name: Upload packages artifacts uses: actions/upload-artifact@v2 with: name: "drop-ci-packages" - path: './temp' \ No newline at end of file + path: './temp' + + - name: Push LLamaSharp packages to nuget.org + run: dotnet nuget push ./temp/LLamaSharp*.nupkg --source https://www.nuget.org -k ${{ secrets.LLAMA_SHARP_NUGET_KEY }} --skip-duplicate diff --git a/.github/workflows/release-patch-trigger.yml b/.github/workflows/release-patch-trigger.yml new file mode 100644 index 000000000..56d2462be --- /dev/null +++ b/.github/workflows/release-patch-trigger.yml @@ -0,0 +1,19 @@ +name: release-patch-trigger + +on: + pull_request: + branches: + - master + types: [ closed ] + +jobs: + trigger_patch_release: + if: contains(github.event.pull_request.labels.*.name, 'patch-release') && !contains(github.event.pull_request.labels.*.name, 'minor-release') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET 6.0.x SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x \ No newline at end of file diff --git a/.github/workflows/release-patch.yml b/.github/workflows/release-patch.yml new file mode 100644 index 000000000..39121b967 --- /dev/null +++ b/.github/workflows/release-patch.yml @@ -0,0 +1,50 @@ +name: auto-release + +on: + workflow_run: + workflows: ["release-patch-trigger"] + types: + - completed + +env: + NUGET_API_TOKEN: ${{ secrets.LLAMA_SHARP_NUGET_KEY }} + +jobs: + patch_release_to_nuget: + runs-on: ubuntu-latest + + steps: + - name: Setup NuGet + uses: nuget/setup-nuget@v1 + with: + nuget-api-key: $NUGET_API_TOKEN + nuget-version: 'latest' + + - name: Check .NET info + run: dotnet --info + + - name: Install dependencies + run: dotnet restore + + - name: Build solution + run: | + dotnet build ./LLama/LLamaSharp.csproj -c Release --no-restore + dotnet build ./LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj -c Release --no-restore + + - name: Pack packages + run: | + git fetch --unshallow; + git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"; + git fetch origin; + + chmod +x ./.github/prepare_release.sh + ./.github/prepare_release.sh false true + + - name: Upload packages artifacts + uses: actions/upload-artifact@v2 + with: + name: "drop-ci-packages" + path: './temp' + + - name: Push LLamaSharp packages to nuget.org + run: dotnet nuget push ./temp/LLamaSharp*.nupkg --source https://www.nuget.org -k ${{ secrets.LLAMA_SHARP_NUGET_KEY }} --skip-duplicate diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 799d3656a..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: auto-release - -on: - workflow_run: - workflows: ["release-prepare"] - types: - - completed - -env: - NUGET_API_TOKEN: ${{ secrets.LLAMA_SHARP_NUGET_KEY }} - -jobs: - release_to_nuget: - runs-on: ubuntu-latest - - steps: - - name: Download Artifact - uses: dawidd6/action-download-artifact@v2 - with: - name: drop-ci-packages - workflow: release-prepare.yml - branch: master - - - name: Push LLamaSharp packages to nuget.org - run: | - ls - ls ./temp - dotnet nuget push ./temp/LLamaSharp*.nupkg --source https://www.nuget.org -k ${{ secrets.LLAMA_SHARP_NUGET_KEY }} --skip-duplicate From a5e66b31dcd946c714795c0250a50d3d5a42e7c8 Mon Sep 17 00:00:00 2001 From: Yaohui Liu Date: Wed, 25 Oct 2023 00:45:49 +0800 Subject: [PATCH 2/2] ci: fix typo. --- .github/workflows/release-minor-trigger.yml | 3 ++- .github/workflows/release-patch-trigger.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-minor-trigger.yml b/.github/workflows/release-minor-trigger.yml index f9b3452c2..6d4de7be5 100644 --- a/.github/workflows/release-minor-trigger.yml +++ b/.github/workflows/release-minor-trigger.yml @@ -16,4 +16,5 @@ jobs: - name: Setup .NET 6.0.x SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x \ No newline at end of file + dotnet-version: 6.0.x + \ No newline at end of file diff --git a/.github/workflows/release-patch-trigger.yml b/.github/workflows/release-patch-trigger.yml index 56d2462be..41ec4f840 100644 --- a/.github/workflows/release-patch-trigger.yml +++ b/.github/workflows/release-patch-trigger.yml @@ -16,4 +16,5 @@ jobs: - name: Setup .NET 6.0.x SDK uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x \ No newline at end of file + dotnet-version: 6.0.x + \ No newline at end of file