Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ master ]

permissions:
contents: read
contents: write
packages: write

env:
Expand Down Expand Up @@ -70,7 +70,14 @@ 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
run: |
dotnet pack --configuration Release --no-build -o ./nupkg
dotnet nuget push ./nupkg/*.nupkg --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: ./CI_Pack_Push.ps1
env:
GITHUB_NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
REPO_OWNER: ${{ github.repository_owner }}
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release

on:
release:
types: [published]

permissions:
contents: write
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: 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 }}
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 }}
11 changes: 11 additions & 0 deletions CI_Pack_Push.ps1
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions LogicBuilder.Workflow.ComponentModel.Serialization.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<Folder Name="/Solution Items/">
<File Path=".github/workflows/check-for-ab-number.yml" />
<File Path=".github/workflows/ci.yml" />
<File Path=".github/workflows/release.yml" />
<File Path="CI_Pack_Push.ps1" />
<File Path="Release_Pack_Push.ps1" />
</Folder>
<Project Path="LogicBuilder.Workflow.ComponentModel.Serialization/LogicBuilder.Workflow.ComponentModel.Serialization.csproj" />
<Project Path="Workflow.ComponentModel.Serialization.Tests/Workflow.ComponentModel.Serialization.Tests.csproj" Id="1b5e3f1c-42ee-4114-af6f-b3044bfba6c3" />
Expand Down
12 changes: 12 additions & 0 deletions Release_Pack_Push.ps1
Original file line number Diff line number Diff line change
@@ -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
}