From 176fe45a90f3cfda16fe20569079daa45f4441cc Mon Sep 17 00:00:00 2001 From: Blaise Taylor Date: Thu, 5 Feb 2026 10:06:47 -0500 Subject: [PATCH 1/2] AB#16 Testing release to GitHub Packages only. --- .github/workflows/ci.yml | 8 +- .github/workflows/release.yml | 85 +++++++++++++++++++ CI_Pack_Push.ps1 | 11 +++ ...Workflow.ComponentModel.Serialization.slnx | 3 + Release_Pack_Push.ps1 | 12 +++ 5 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 CI_Pack_Push.ps1 create mode 100644 Release_Pack_Push.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b95506..292e426 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,8 @@ jobs: run: dotnet build --no-restore --configuration Release - name: Publish to GitHub Packages - run: | - dotnet pack --configuration Release --no-build -o ./nupkg - dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + run: ./CI_Pack_Push.ps1 + env: + GITHUB_NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + REPO_OWNER: ${{ github.repository_owner }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..83ec3ae --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +name: Release + +on: + release: + types: [published] + +permissions: + contents: read + packages: write + # id-token: write + +env: + DOTNET_VERSION: "10.0.x" + NODE_VERSION: "20" + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + + - name: Restore dependencies + run: dotnet restore + + - name: Build project + run: dotnet build --no-restore --configuration Release + + - name: Run unit tests + run: dotnet test --no-build --verbosity normal --configuration Release /p:CollectCoverage=true /p:Threshold=50 /p:ThresholdType=line /p:ThresholdStat=Average /p:CoverletOutput=./TestResults/ /p:ExcludeByAttribute="GeneratedCodeAttribute" + + publish-packages: + name: Publish Package to GitHub Packages and NuGet.org + runs-on: ubuntu-latest + needs: test + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + source-url: https://nuget.pkg.github.com/bpsLogicBuilder/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: NuGet login + # uses: NuGet/login@v1 + # id: nuget_login + # with: + # user: ${{ secrets.NUGET_USER }} + + - name: Restore dependencies + run: dotnet restore + + - name: Build project + run: dotnet build --no-restore --configuration Release + + - name: Publish Packages + run: ./Release_Pack_Push.ps1 + env: + REPO: ${{ github.repository }} + REPO_OWNER: ${{ github.repository_owner }} + NUGET_URL: 'https://api.nuget.org/v3/index.json' + GITHUB_NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # NUGET_API_KEY: ${{ steps.nuget_login.outputs.NUGET_API_KEY }} diff --git a/CI_Pack_Push.ps1 b/CI_Pack_Push.ps1 new file mode 100644 index 0000000..78613b3 --- /dev/null +++ b/CI_Pack_Push.ps1 @@ -0,0 +1,11 @@ +$scriptName = $MyInvocation.MyCommand.Name + +Write-Host "Owner ${Env:REPO_OWNER}" +Write-Host "Repository ${Env:REPO}" + +if ($Env:REPO_OWNER -ne "BpsLogicBuilder") { + Write-Host "${scriptName}: Only create packages on BpsLogicBuilder repositories." +} else { + dotnet pack --configuration Release -o ./nupkg --no-build + dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --api-key $Env:GITHUB_NUGET_AUTH_TOKEN +} \ No newline at end of file diff --git a/LogicBuilder.Workflow.ComponentModel.Serialization.slnx b/LogicBuilder.Workflow.ComponentModel.Serialization.slnx index 067fb25..677966b 100644 --- a/LogicBuilder.Workflow.ComponentModel.Serialization.slnx +++ b/LogicBuilder.Workflow.ComponentModel.Serialization.slnx @@ -2,6 +2,9 @@ + + + diff --git a/Release_Pack_Push.ps1 b/Release_Pack_Push.ps1 new file mode 100644 index 0000000..d3e345a --- /dev/null +++ b/Release_Pack_Push.ps1 @@ -0,0 +1,12 @@ +$scriptName = $MyInvocation.MyCommand.Name + +Write-Host "Owner ${Env:REPO_OWNER}" +Write-Host "Repository ${Env:REPO}" + +if ($Env:REPO_OWNER -ne "BpsLogicBuilder") { + Write-Host "${scriptName}: Only create packages on BpsLogicBuilder repositories." +} else { + dotnet pack --configuration Release -o ./nupkg --no-build + dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --api-key $Env:GITHUB_NUGET_AUTH_TOKEN + # dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --source $Env:NUGET_URL --api-key $Env:NUGET_API_KEY +} From 5eb9039885913fa58b3a72c9113fa7a027b6cd5d Mon Sep 17 00:00:00 2001 From: Blaise Taylor Date: Thu, 5 Feb 2026 10:23:49 -0500 Subject: [PATCH 2/2] AB#16 Trying again on permissions denied. --- .github/workflows/ci.yml | 7 ++++++- .github/workflows/release.yml | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 292e426..afb2d77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: branches: [ master ] permissions: - contents: read + contents: write packages: write env: @@ -70,7 +70,12 @@ jobs: - name: Build project run: dotnet build --no-restore --configuration Release + - name: Make script executable + run: chmod +x ./CI_Pack_Push.ps1 + shell: bash + - name: Publish to GitHub Packages + shell: pwsh run: ./CI_Pack_Push.ps1 env: GITHUB_NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83ec3ae..769b4af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: types: [published] permissions: - contents: read + contents: write packages: write # id-token: write @@ -75,7 +75,12 @@ jobs: - name: Build project run: dotnet build --no-restore --configuration Release + - name: Make script executable + run: chmod +x ./Release_Pack_Push.ps1 + shell: bash + - name: Publish Packages + shell: pwsh run: ./Release_Pack_Push.ps1 env: REPO: ${{ github.repository }}