From 9a944729371247e8fd5eb5d0da5c3fd749642e6d Mon Sep 17 00:00:00 2001 From: Alexander Linne Date: Fri, 24 May 2024 17:25:58 +0200 Subject: [PATCH] ci: add deploy job Signed-off-by: Alexander Linne --- .github/workflows/build.yaml | 26 ++++++++++++++++++++++++++ Travis/deploy.ps1 | 6 ------ Travis/test_linux.sh | 3 --- Travis/test_windows.ps1 | 28 ---------------------------- 4 files changed, 26 insertions(+), 37 deletions(-) delete mode 100644 Travis/deploy.ps1 delete mode 100644 Travis/test_linux.sh delete mode 100644 Travis/test_windows.ps1 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3dfb81a20..44d132352 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "[0-9]+.[0-9]+.[0-9]+" pull_request: types: [opened, reopened, synchronize] @@ -53,3 +55,27 @@ jobs: dotnet-version: 8.0.300 - name: Run tests run: dotnet test -c Debug + deploy: + name: Deploy + if: github.ref == 'refs/tags/[0-9]+.[0-9]+.[0-9]+' + runs-on: windows-latest + environment: deploy + needs: + - formatting + - coverage + - run-tests + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - name: Setup .NET + uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 + with: + dotnet-version: 8.0.300 + - name: Add package source + run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org + - name: Build + run: dotnet build -c Release + - name: Pack + run: dotnet pack -c Release --output nupkgs -p:PackageVersion="${{ github.ref_name }}" -p:AssemblyVersion="${{ github.ref_name }}.0" + - name: Push + run: dotnet nuget push nupkgs/*.nupkg --source nuget.org --api-key ${{ secrets.NUGET_API_KEY }} diff --git a/Travis/deploy.ps1 b/Travis/deploy.ps1 deleted file mode 100644 index 2e6b448cd..000000000 --- a/Travis/deploy.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -param( -[string]$apiKey, -[string]$source -) - -dotnet nuget push ($PWD.Path + "\nupkgs\TngTech.ArchUnitNET.*.nupkg") -k $apiKey -s $source diff --git a/Travis/test_linux.sh b/Travis/test_linux.sh deleted file mode 100644 index 1404ee242..000000000 --- a/Travis/test_linux.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -set -ev -dotnet test -c Debug --framework net6.0 diff --git a/Travis/test_windows.ps1 b/Travis/test_windows.ps1 deleted file mode 100644 index 1a30c6c0d..000000000 --- a/Travis/test_windows.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -param( - [string]$tag -) -New-Variable -Name "VERSION_PATTERN" -Value "^[0-9]+\.[0-9]+\.[0-9]" - -dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org - -dotnet build -c Release - -if ($LASTEXITCODE -eq 1){ - Write-Output "dotnet build failed" - exit 1 -} - -if("$tag" -eq "") -{ - dotnet pack -c Release --output nupkgs -p:PackageVersion="0.0.0" -p:AssemblyVersion="0.0.0.0" -} -elseif ("$tag" -match $VERSION_PATTERN) -{ - dotnet pack -c Release --output nupkgs -p:PackageVersion="$tag" -p:AssemblyVersion="$tag.0" -} -else -{ - Write-Output "Git Tag has to resemble a package version (e.g. 1.0.0)." - exit 1 -} -dotnet test -c Debug