From d5e02c7ca2557a5e75edccb5214c1e79c50786f2 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Thu, 7 Mar 2024 10:40:25 +0100 Subject: [PATCH] Add release steps for libs in actions pipeline --- .github/workflows/build-and-test.yml | 17 +++++++--------- .github/workflows/pipeline.yml | 20 +++++++++++++++++-- .github/workflows/release-package.yml | 28 +++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/release-package.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fc1b033..b8d6656 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,7 +6,6 @@ on: jobs: windows: runs-on: windows-latest - name: "[windows] Build and test" steps: - name: Checkout uses: actions/checkout@v4 @@ -15,13 +14,12 @@ jobs: with: dotnet-version: 8.x.x - name: Build - run: dotnet build ./arc-validate-package-registry.sln + run: dotnet build ./arc-validate-package-registry.sln --configuration Release - name: Test - run: dotnet test ./arc-validate-package-registry.sln + run: dotnet test ./arc-validate-package-registry.sln --configuration Release --no-build ubuntu: runs-on: ubuntu-latest - name: "[ubuntu] Build and test" steps: - name: Checkout uses: actions/checkout@v4 @@ -30,13 +28,12 @@ jobs: with: dotnet-version: 8.x.x - name: Build - run: dotnet build ./arc-validate-package-registry.sln + run: dotnet build ./arc-validate-package-registry.sln --configuration Release - name: Test - run: dotnet test ./arc-validate-package-registry.sln + run: dotnet test ./arc-validate-package-registry.sln --configuration Release --no-build macos: runs-on: macos-latest - name: "[macOS] Build and test" steps: - name: Checkout uses: actions/checkout@v4 @@ -45,6 +42,6 @@ jobs: with: dotnet-version: 8.x.x - name: Build - run: dotnet build ./arc-validate-package-registry.sln - - name: Test - run: dotnet test ./arc-validate-package-registry.sln \ No newline at end of file + run: dotnet build ./arc-validate-package-registry.sln --configuration Release + - name: Test + run: dotnet test ./arc-validate-package-registry.sln --configuration Release --no-build \ No newline at end of file diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5d88b1f..37b52f6 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -95,10 +95,26 @@ jobs: echo "dry run:" echo "${{ steps.decide-on-dry-run.outputs.dry_run }}" - build: + build-and-test: needs: setup # https://github.com/actions/runner/issues/1173 if: (needs.setup.outputs.tests_any_changed == 'true' || needs.setup.outputs.api_any_changed == 'true' || needs.setup.outputs.client_any_changed == 'true' || needs.setup.outputs.index_any_changed == 'true') && needs.setup.outputs.is_dry_run == 'false' uses: nfdi4plants/arc-validate-package-registry/.github/workflows/build-and-test.yml@main - \ No newline at end of file + release-index: + needs: [setup, build-and-test] + if: needs.setup.outputs.is_dry_run == 'false' && contains(needs.setup.outputs.index_all_changed_files, 'RELEASE_NOTES.md') + uses: nfdi4plants/arc-validate-package-registry/.github/workflows/release-package.yml@main + with: + package: project + secrets: + NUGET_KEY: ${{ secrets.NUGET_KEY }} + + release-client: + needs: [setup, build-and-test] + if: needs.setup.outputs.is_dry_run == 'false' && contains(needs.setup.outputs.client_all_changed_files, 'RELEASE_NOTES.md') + uses: nfdi4plants/arc-validate-package-registry/.github/workflows/release-package.yml@main + with: + package: client + secrets: + NUGET_KEY: ${{ secrets.NUGET_KEY }} \ No newline at end of file diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml new file mode 100644 index 0000000..a3bb05e --- /dev/null +++ b/.github/workflows/release-package.yml @@ -0,0 +1,28 @@ +name: "Release Packages" + +on: + workflow_call: + inputs: + project: + required: true + type: string + description: "The project to release" + secrets: + NUGET_KEY: + required: true + description: "The key that allows pushing packages to nuget" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x.x + - name: pack + run: dotnet pack ${{ github.event.inputs.project }} --configuration Release -o ./pkg + - name: push + run: dotnet nuget push ./pkg/*.nupkg --api-key ${{ secrets.nuget_key }} --source https://api.nuget.org/v3/index.json \ No newline at end of file