From 330420ed64ac398f7769fb89d2a105d7d10bcc21 Mon Sep 17 00:00:00 2001 From: Nik Date: Sun, 17 Dec 2023 10:59:33 +0000 Subject: [PATCH 1/2] [AMEND] Update workflow with various conditions --- .github/workflows/build-and-release.yml | 52 +++++++++++++++++++++++++ .github/workflows/release.yml | 39 ------------------- 2 files changed, 52 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/build-and-release.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 0000000..29ba7b9 --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,52 @@ +name: Build and Release Package + +# This action will start when a correctly formatted tag is pushed (e.g. v0.1.0) + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + + - name: Set Version Variable + if: ${{ github.ref_type == 'tag' }} + env: + TAG: ${{ github.ref_name }} + run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup .NET 6 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Setup .NET 7 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 7.0.x + + - name: Setup .NET 8 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 8.0.x + + - name: Build project + run: dotnet build src\HC.PageNotFoundManager\HC.PageNotFoundManager.csproj --configuration Release /p:Version=$VERSION + + - name: Pack project + run: dotnet pack --output nupkgs /p:PackageVersion=$VERSION .\src\PageNotFoundManager.sln + + - name: upload nuget package + if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') + run: dotnet nuget push **\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 8730218..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Release Package - -# This action will start when a correctly formatted tag is pushed (e.g. 0.1.0) - -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - -jobs: - build: - - runs-on: windows-latest - - steps: - - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup .NET 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x - - - name: Setup .NET 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 8.0.x - - - name: Build project - run: dotnet build src\HC.PageNotFoundManager\HC.PageNotFoundManager.csproj --configuration Release - - - name: Push to NuGet - run: dotnet nuget push **\*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json From 5ae247377af366ab6148f5604a03eeae1672b6c7 Mon Sep 17 00:00:00 2001 From: Nik Date: Sun, 17 Dec 2023 12:12:26 +0000 Subject: [PATCH 2/2] [AMEND] Changes to workflows --- .github/workflows/build-and-release.yml | 3 -- .github/workflows/build.yml | 50 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 29ba7b9..65c1256 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -6,9 +6,6 @@ on: push: tags: - "v[0-9]+.[0-9]+.[0-9]+" - branches: [ "develop" ] - pull_request: - branches: [ "develop" ] workflow_dispatch: jobs: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f1951a9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build and Release Package + +on: + push: + branches: ["develop"] + pull_request: + branches: ["develop"] + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Get next version + uses: reecetech/version-increment@2023.9.3 + id: version + with: + scheme: semver + increment: patch + release_branch: main + + - name: Set Version Variable + env: + TAG: ${{ steps.version.outputs.version }} + run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV + + - name: Setup .NET 6 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Setup .NET 7 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 7.0.x + + - name: Setup .NET 8 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 8.0.x + + - name: Build project + run: dotnet build src\HC.PageNotFoundManager\HC.PageNotFoundManager.csproj --configuration Release /p:Version=$VERSION + + - name: Pack project + run: dotnet pack --output nupkgs /p:PackageVersion=$VERSION .\src\PageNotFoundManager.sln