diff --git a/.github/workflows/release-minor-trigger.yml b/.github/workflows/release-minor-trigger.yml new file mode 100644 index 000000000..6d4de7be5 --- /dev/null +++ b/.github/workflows/release-minor-trigger.yml @@ -0,0 +1,20 @@ +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..41ec4f840 --- /dev/null +++ b/.github/workflows/release-patch-trigger.yml @@ -0,0 +1,20 @@ +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