Skip to content

Commit 268cfe5

Browse files
A lot of workflow updates. some minor updates to code (#6)
* + gray-ish color for event nodes; node size is 8 by default * + pester tests step * remove some folders from build * update publish workflow * troubleshooting pester tests * more troubleshooting * still troubleshooting * trying to fix tests to run on github actions * another test * one more test * few more tests * another attempt * try again * few more updates to the workflow * + pipeline for publishig common library * bump minor version for testing * fixing version suffix * new publish pipeline * fix some issues with the pipeline * few more fixes as 'v' in front of a version cannot be converted to System.Version * keep fixing version processing for PS anifest * disable auto-start by now * keep fighting with version * was failing to load .net sdk. setting it up * update powershell version on the runner * make sure we have correct suffix * ci: update module version to 2.3.1 * combining common package and module publishing * ci: update module version to 2.3.1 * fixing issues with wrong suffux of a .net package * ci: update module version to 2.3.1 * sync module version and common package version for simplicity * another attempt * fix syntax * ci: update module version to 2.3.1 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c967ab6 commit 268cfe5

4 files changed

Lines changed: 324 additions & 11 deletions

File tree

.github/workflows/publish.yml

Lines changed: 146 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,175 @@ name: psgraph-publish
33
on:
44
release:
55
types: [published]
6-
6+
77
workflow_dispatch:
88

99
jobs:
10-
1110
publish:
1211
runs-on: ubuntu-latest
1312
strategy:
1413
matrix:
15-
dotnet-version: ['9.0.x' ]
14+
dotnet-version: ['9.0.x']
1615

1716
steps:
18-
- uses: actions/checkout@v3
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
1922
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
2023
uses: actions/setup-dotnet@v3
2124
with:
2225
dotnet-version: ${{ matrix.dotnet-version }}
26+
27+
- name: Install PowerShell
28+
uses: PSModule/install-powershell@v1
29+
with:
30+
Version: latest
31+
32+
# --- PowerShell Module Versioning ---
33+
- name: Ensure release tag exists
34+
id: ensure_tag
35+
run: |
36+
if [ -z "${GITHUB_REF##refs/tags/}" ]; then
37+
echo "Error: Release must have a tag."
38+
exit 1
39+
fi
40+
41+
- name: Extract version from tag and update module manifest
42+
id: set_version
43+
shell: pwsh
44+
run: |
45+
$tag = "${env:GITHUB_REF}" -replace '^refs/tags/', ''
46+
if (-not $tag) {
47+
Write-Error "Tag not found. Failing."
48+
exit 1
49+
}
50+
$tag = $tag -replace '^v', ''
51+
if ($tag -match '^([0-9]+\.[0-9]+\.[0-9]+)(?:-([A-Za-z0-9\-]+))?$') {
52+
$version = $matches[1]
53+
$prerelease = $matches[2]
54+
} else {
55+
Write-Error "Tag format invalid. Should be X.Y.Z or X.Y.Z-suffix"
56+
exit 1
57+
}
58+
if ($prerelease -and ($prerelease -notmatch '^(?:-)?[a-zA-Z0-9\-]+$')) {
59+
Write-Error "Prerelease string '$prerelease' contains invalid characters. Only a-z, A-Z, 0-9, and hyphen (-) at the beginning are allowed."
60+
exit 1
61+
}
62+
$psd1 = Get-Item ./PSGraph/PSQuickGraph.psd1
63+
if (-not $psd1) {
64+
Write-Error "Module manifest (.psd1) not found!"
65+
exit 1
66+
}
67+
$content = Get-Content $psd1.FullName
68+
$versionPattern = 'ModuleVersion\s*=\s*''[^'']*'''
69+
$content = $content -replace $versionPattern, "ModuleVersion = '$version'"
70+
if ($prerelease) {
71+
$content = $content -replace '^\s*#\s*Prerelease\s*=\s*''[^'']*''', "Prerelease = '$prerelease'"
72+
}
73+
Set-Content -Path $psd1.FullName -Value $content
74+
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
75+
"prerelease=$prerelease" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
76+
77+
# --- PowerShell Module Build/Test/Publish ---
2378
- name: Install dependencies
2479
run: dotnet restore
25-
- name: Build
26-
run: dotnet build
27-
- name: Test
80+
81+
- name: Build PowerShell module
82+
run: |
83+
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
84+
dotnet build -c Debug
85+
else
86+
dotnet build -c Release
87+
fi
88+
89+
- name: Run .NET tests
2890
run: dotnet test --verbosity normal
91+
2992
- name: Pester tests
3093
shell: pwsh
3194
run: |
3295
Invoke-Pester -Path ./PsGraph.Pester.Tests/
96+
3397
- name: dotnet publish
3498
run: dotnet publish -o "./PSQuickGraph"
99+
35100
- name: psgallery publish
36101
run: |
37-
$env:GITHUB_WORKSPACE
38-
Publish-Module -Path "./PSQuickGraph" -NuGetApiKey ${{ secrets.PS_GALLERY_SECRET }}
102+
Invoke-Pester -Path ./PsGraph.Pester.Tests/
103+
104+
- name: dotnet publish PowerShell module
105+
run: |
106+
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
107+
dotnet publish -c Debug -o "./PSQuickGraph"
108+
else
109+
dotnet publish -c Release -o "./PSQuickGraph"
110+
fi
111+
112+
- name: Publish PowerShell module to PSGallery
39113
shell: pwsh
40-
114+
run: |
115+
Publish-Module -Path "./PSQuickGraph" -NuGetApiKey ${{ secrets.PS_GALLERY_SECRET }}
41116
117+
# --- NuGet Common Package Build/Publish ---
118+
- name: Set Version Suffix for Pre-release (Common)
119+
if: github.event.release.prerelease == true
120+
run: |
121+
echo "VERSION_SUFFIX=${{ steps.set_version.outputs.prerelease }}" >> $GITHUB_ENV
122+
123+
- name: Build PSGraph.Common (Debug on prerelease, Release on release)
124+
run: |
125+
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
126+
dotnet build PSGraph.Common/PSGraph.Common.csproj --configuration Debug --no-restore
127+
else
128+
dotnet build PSGraph.Common/PSGraph.Common.csproj --configuration Release --no-restore
129+
fi
130+
131+
- name: Pack PSGraph.Common (Debug/pre-release on prerelease, Release on release)
132+
shell: bash
133+
run: |
134+
if [ "${{ github.event.release.prerelease }}" = "true" ]; then
135+
VERSION="${{ steps.set_version.outputs.version }}-${{ steps.set_version.outputs.prerelease }}"
136+
dotnet pack PSGraph.Common/PSGraph.Common.csproj \
137+
--configuration Debug \
138+
--no-build \
139+
--output ./nupkg \
140+
/p:PackageVersion="$VERSION"
141+
else
142+
VERSION="${{ steps.set_version.outputs.version }}"
143+
dotnet pack PSGraph.Common/PSGraph.Common.csproj \
144+
--configuration Release \
145+
--no-build \
146+
--output ./nupkg \
147+
/p:PackageVersion="$VERSION"
148+
fi
149+
150+
- name: Publish PSGraph.Common to NuGet
151+
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
152+
env:
153+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
154+
155+
# --- Commit manifest changes ---
156+
- name: Commit and push updated manifest
157+
if: success()
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
run: |
161+
git config user.name "github-actions[bot]"
162+
git config user.email "github-actions[bot]@users.noreply.github.com"
163+
SOURCE_BRANCH="${{ github.event.release.target_commitish }}"
164+
if [ -z "$SOURCE_BRANCH" ]; then
165+
echo "Could not determine source branch. Exiting."
166+
exit 1
167+
fi
168+
if [[ "$SOURCE_BRANCH" =~ ^[0-9a-f]{40}$ ]]; then
169+
echo "Commitish is a SHA, not a branch name. Aborting."
170+
exit 1
171+
fi
172+
git fetch origin "$SOURCE_BRANCH"
173+
git switch "$SOURCE_BRANCH"
174+
git pull origin "$SOURCE_BRANCH"
175+
git add ./PSQuickGraph/*.psd1
176+
git commit -m "ci: update module version to ${{ steps.set_version.outputs.version }}" || echo "Nothing to commit"
177+
git push origin "$SOURCE_BRANCH"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish PSGraph.Common NuGet Package
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-and-publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Setup .NET
15+
uses: actions/setup-dotnet@v4
16+
with:
17+
dotnet-version: '9.0.x'
18+
19+
- name: Restore dependencies
20+
run: dotnet restore PSGraph.Common/PSGraph.Common.csproj
21+
22+
- name: Set Version Suffix for Pre-release
23+
if: github.ref == 'refs/heads/dev'
24+
run: |
25+
VERSION_SUFFIX="beta-$(date +%Y%m%d%H%M%S)"
26+
echo "VERSION_SUFFIX=$VERSION_SUFFIX" >> $GITHUB_ENV
27+
28+
- name: Build (Debug on dev, Release on main)
29+
run: |
30+
if [ "${{ github.ref }}" = "refs/heads/dev" ]; then
31+
dotnet build PSGraph.Common/PSGraph.Common.csproj --configuration Debug --no-restore
32+
else
33+
dotnet build PSGraph.Common/PSGraph.Common.csproj --configuration Release --no-restore
34+
fi
35+
36+
- name: Pack (Debug/pre-release on dev, Release on main)
37+
run: |
38+
if [ "${{ github.ref }}" = "refs/heads/dev" ]; then
39+
dotnet pack PSGraph.Common/PSGraph.Common.csproj \
40+
--configuration Debug \
41+
--no-build \
42+
--output ./nupkg \
43+
--version-suffix $VERSION_SUFFIX
44+
else
45+
dotnet pack PSGraph.Common/PSGraph.Common.csproj \
46+
--configuration Release \
47+
--no-build \
48+
--output ./nupkg
49+
fi
50+
51+
- name: Publish to NuGet
52+
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
53+
env:
54+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

PSGraph.Common/PSGraph.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<Version>1.0.1</Version>
7+
<VersionPrefix>1.0.3</VersionPrefix>
88
<Authors>Andrey Vernigora</Authors>
99
<PackageId>PSGraph.Common</PackageId>
1010
<Description>Common types of PSGraph module</Description>

PSQuickGraph/PSQuickGraph.psd1

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#
2+
# Module manifest for module 'PSGraph'
3+
#
4+
# Generated by: Andrei
5+
#
6+
# Generated on: 07.04.2017
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = "PSGraph.dll"
13+
14+
# Version number of this module.
15+
ModuleVersion = '2.3.1'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
19+
20+
# ID used to uniquely identify this module
21+
GUID = '4bd5a906-8e03-497e-80eb-209e71caae45'
22+
23+
# Author of this module
24+
Author = 'Andrey Vernigora'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Unknown'
28+
29+
# Copyright statement for this module
30+
Copyright = '(c) 2017 Andrei. All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'This module is a wrapper for QuickGraph library.'
34+
35+
# Minimum version of the Windows PowerShell engine required by this module
36+
# PowerShellVersion = ''
37+
38+
# Name of the Windows PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the Windows PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# CLRVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
RequiredModules = @()
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @("QuickGraph.dll", "QuickGraph.Data.dll", "QuickGraph.Graphviz.dll", "QuickGraph.Serialization.dll", "GraphSharp.dll", "GraphSharp.Controls.dll")
58+
RequiredAssemblies = @()
59+
60+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
61+
# ScriptsToProcess = @()
62+
63+
# Type files (.ps1xml) to be loaded when importing this module
64+
# TypesToProcess = @()
65+
66+
# Format files (.ps1xml) to be loaded when importing this module
67+
# FormatsToProcess = @()
68+
69+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
70+
# NestedModules = @()
71+
72+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
73+
FunctionsToExport = @()
74+
75+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
76+
CmdletsToExport = @("*")
77+
78+
# Variables to export from this module
79+
VariablesToExport = '*'
80+
81+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
82+
AliasesToExport = @()
83+
84+
# DSC resources to export from this module
85+
# DscResourcesToExport = @()
86+
87+
# List of all modules packaged with this module
88+
# ModuleList = @()
89+
90+
# List of all files packaged with this module
91+
# FileList = @()
92+
93+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
94+
PrivateData = @{
95+
96+
PSData = @{
97+
Prerelease = 'beta6'
98+
# Tags applied to this module. These help with module discovery in online galleries.
99+
# Tags = @()
100+
101+
# A URL to the license for this module.
102+
# LicenseUri = ''
103+
104+
# A URL to the main website for this project.
105+
ProjectUri = 'https://github.com/eosfor/PSGraph'
106+
107+
# A URL to an icon representing this module.
108+
# IconUri = ''
109+
110+
# ReleaseNotes of this module
111+
# ReleaseNotes = ''
112+
113+
} # End of PSData hashtable
114+
115+
} # End of PrivateData hashtable
116+
117+
# HelpInfo URI of this module
118+
# HelpInfoURI = ''
119+
120+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
121+
# DefaultCommandPrefix = ''
122+
123+
}

0 commit comments

Comments
 (0)