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
78 changes: 51 additions & 27 deletions .github/workflows/build-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@ name: Build, Test, Pack, Zip, and Publish
on:
push:
branches: [ master, develop ]
# tags:
# - 'v*'
pull_request:
branches: [ master, develop ]



env:
# Update to desired major.minor. This is the base version family.
BASE_VERSION: "2.1"
PATH_SLNX: "source\\Lite.StateMachine.slnx"
PATH_LIB: "source\\Lite.StateMachine\\Lite.StateMachine.csproj"
PATH_ARTIFACTS: ${{github.workspace}}\artifacts

jobs:
build-test-pack:
runs-on: windows-latest

env:
# Update to desired major.minor. This is the base version family.
BASE_VERSION: "2.1"
PATH_SLNX: "source/Lite.StateMachine.slnx"
PATH_LIB: "source/Lite.StateMachine/Lite.StateMachine.csproj"

## This job runs if the ref is a branch
##if: startsWith(github.ref, 'refs/heads/')
steps:
# 1. Checkout repository code
- name: 1) Checkout Repository Code
Expand All @@ -43,6 +49,7 @@ jobs:
run: dotnet test ${{env.PATH_SLNX}} --configuration Release --no-build --verbosity normal

# 6. Determin SemVersion package version
# "$run" is based on GitHub Action's Workflow "Runs" counter.
- name: 6) Determine Version for Package
shell: pwsh
run: |
Expand Down Expand Up @@ -75,7 +82,9 @@ jobs:

# 7. Pack NuGet
- name: 7) Pack NuGet
run: dotnet pack ${{env.PATH_LIB}} --configuration Release --no-build --output ./artifacts
# Optionally, "--include-symbols"
run: dotnet pack ${{env.PATH_LIB}} --configuration Release --no-build --output ${{env.PATH_ARTIFACTS}}
# dotnet pack source/Lite.StateMachine/Lite.StateMachine.csproj --configuration Release --no-build --output ./artifacts
#- name: Pack NuGet
# shell: pwsh
# run: |
Expand All @@ -86,32 +95,47 @@ jobs:
# /p:PackageVersion=$version `
# /p:Version=$version `
# /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg `
# --output ./artifacts
# --output ${{env.PATH_ARTIFACTS}}


## 8. Create ZIP of artifacts
##- name: 8) Create ZIP archive
## run: |
## mkdir ./zip
## powershell Compress-Archive -Path ${{env.PATH_ARTIFACTS}}\* -DestinationPath ./zip/artifacts.zip

## #shell: pwsh
## #run: |
## # New-Item -ItemType Directory -Force -Path ./zip | Out-Null
## # Compress-Archive -Path ./artifacts/* -DestinationPath ./zip/artifacts.zip

## 9. Upload ZIP as workflow artifact
##- name: 9) Upload ZIP
## uses: actions/upload-artifact@v4
## with:
## name: nuget-package-zip
## path: ./zip/artifacts.zip

## publish-nuget:
## runs-on: windows-latest
##
## # This job runs only if the ref is a tag
## if: startsWith(github.ref, 'refs/tags/')
## steps:

## 10) Publish to NuGet.org (master branch, push events only)
- name: 8) NuGet Push Package
if: startsWith(github.ref, 'refs/tags/')
env:
NUGET_API_URL: "https://api.nuget.org/v3/index.json"

# 8. Create ZIP of artifacts
- name: 8) Create ZIP archive
run: |
mkdir ./zip
powershell Compress-Archive -Path ./artifacts/* -DestinationPath ./zip/artifacts.zip

#shell: pwsh
#run: |
# New-Item -ItemType Directory -Force -Path ./zip | Out-Null
# Compress-Archive -Path ./artifacts/* -DestinationPath ./zip/artifacts.zip

# 9. Upload ZIP as workflow artifact
- name: 9) Upload ZIP
uses: actions/upload-artifact@v4
with:
name: nuget-package-zip
path: ./zip/artifacts.zip
## Optionally pass, `--skip-duplicate` if a pkg version already exists on NuGet.org
run: dotnet nuget push ${{env.PATH_ARTIFACTS}}\*.nupkg -k ${{secrets.NUGET_AUTH_TOKEN}} -s ${{env.NUGET_API_URL}}

## 10) Publish to NuGet.org (master branch, push events only)
#- name: Publish to NuGet.org
# if: github.ref_name == 'master' && github.event_name == 'push'
# env:
# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
# NUGET_API_KEY: ${{ secrets.NUGET_AUTH_TOKEN }}
# shell: pwsh
# run: |
# # Push .nupkg first
Expand Down
2 changes: 1 addition & 1 deletion source/Lite.StateMachine/Lite.StateMachine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyVersion>2.1.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<VersionPrefix>$(AssemblyVersion)</VersionPrefix>
<VersionSuffix>-beta1</VersionSuffix>
<VersionSuffix>-beta2</VersionSuffix>
<Version>$(VersionPrefix)$(VersionSuffix)</Version>

<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down