Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add publishing chocolatey package to release flow #22

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a0bcc09
Updated docs to be more unified in their appearance where information…
darksidemilk Sep 5, 2024
2dd93db
Added icon to module files and included staically.io cdn version of i…
darksidemilk Sep 5, 2024
c860824
Added chocolatey packaging that includes the psgetmoduleinfo.xml to i…
darksidemilk Sep 5, 2024
58ea84c
Added comment in the set-fogserversettings function help and a warnin…
darksidemilk Sep 5, 2024
6c2cc06
Updated and unified various docs, added icon packaging with best prac…
darksidemilk Sep 5, 2024
adb21eb
use '-' instead of '*' in markdown formats
darksidemilk Sep 5, 2024
da4bb3f
verbage fix and add forums link
darksidemilk Sep 5, 2024
10c869a
unify the overview docs
darksidemilk Sep 5, 2024
1c81693
Fix choco template issue of typo of folder name sources vs files
darksidemilk Sep 8, 2024
376a735
Shortened the manifest and nuspec description
darksidemilk Sep 8, 2024
ae1c302
Update files section of nuspec
darksidemilk Sep 8, 2024
e33d799
Fix choco package building issue where not all files were being prope…
darksidemilk Sep 8, 2024
7143780
commented out bin files spec
darksidemilk Sep 8, 2024
b3e8d69
Added gpu properties to get-foginventory for upcoming add of gpu info…
darksidemilk Sep 9, 2024
9788c73
Added nuspec and psgetmodule info templates
darksidemilk Sep 10, 2024
e48e4d7
Updates to release note formatting, manifest description format, and …
darksidemilk Sep 11, 2024
463eb52
Updated Send-FogImage with params for 1.6 and added switch options an…
darksidemilk Sep 11, 2024
4c2233e
Filter out rdp display driver when getting host inventory details and…
darksidemilk Sep 11, 2024
f436a65
revert change of appending gpu ram as it doesn't work for all gpus eq…
darksidemilk Sep 11, 2024
7ceb4e5
Update tag-and-release.yml
darksidemilk Sep 14, 2024
e0929ad
Merge branch 'master' into 21-add-publishing-chocolatey-package-to-re…
darksidemilk Sep 14, 2024
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
12 changes: 6 additions & 6 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ jobs:
gh release upload $version ".\_module_build\FogApi.$version.psgallery.nupkg"
gh release upload $version ".\_module_build\FogApi.$version.BuiltModule.zip"

"building choco package..." | out-host;
.\build-choco.ps1;
"building choco package from local build and temp psresource repo..." | out-host;
.\build-choco.ps1 -uselocal;

"adding choco package to release" | out-host;
copy-item ".\FogApi.$version.nupkg" ".\FogApi.$version.chocolatey.nupkg"
gh release upload $version ".\FogApi.$version.chocolatey.nupkg"
remove-item ".\FogApi.$version.chocolatey.nupkg" -force -recurse -ea 0;

"publishing choco package..." | out-host;
choco apikey add -s "https://push.chocolatey.org/" -k="$env:ChocoKey"
choco apikey add -s "https://community.chocolatey.org/api/v2/" -k="$env:ChocoKey"
choco push "FogApi.$version.nupkg" --source https://push.chocolatey.org/
#"publishing choco package..." | out-host;
#choco apikey add -s "https://push.chocolatey.org/" -k="$env:ChocoKey"
#choco apikey add -s "https://community.chocolatey.org/api/v2/" -k="$env:ChocoKey"
#choco push "FogApi.$version.nupkg" --source https://push.chocolatey.org/



Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_build
_module_build
.lastprereqrun
.vscode
.vscode
.nupkg
119 changes: 60 additions & 59 deletions FogApi/FogApi.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JJ Fullmer
#
# Generated on: 9/4/2024
# Generated on: 9/11/2024
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'FogApi.psm1'

# Version number of this module.
ModuleVersion = '2409.9.4'
ModuleVersion = '2409.9.15'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -30,64 +30,63 @@ CompanyName = 'FOG Project'
Copyright = '2018-2024'

# Description of the functionality provided by this module
Description = 'This module is used to easily run Fog API commands on your fogserver from a powershell console or script.
This essentially gives you a crossplatform commandline interface for fog tasks and makes many things easier to automate.
You can install FOG Project from https://github.com/FogProject/fogproject
Description = '
# FOG Api Powershell Module

The documentation is hosted on readthedocs at https://fogapi.readthedocs.io/en/latest/
This is a powershell module to simplify the use of the Fog Project API.
This module is used to easily run Fog API commands on your fogserver from a powershell console or script.
FOG is an opensource tool for imaging comptuters, this module uses the API on your internal fog server to
perform almost any operation you can do in the GUI of Fog and provides you with the ability to extend things further.
It can be used to create more automation or to simply have a command line method of controlling fog operations.
This essentially gives you a crossplatform commandline interface for fog tasks and makes many things easier to automate.

To install this module you need at least powershell v3, was created with 5.1 and intended to be cross platform compatible with powershell v6
To Install this module follow these steps

* Easiest method: Install from PSGallery https://www.powershellgallery.com/packages/FogApi `Install-Module -name fogApi` or `Install-PSResource -Name FogApi -TrustRepository -repository PSGallery`
Docs for this module can be found at https://fogapi.readthedocs.io/en/latest/

* Install with chocolatey (will install the module by copying the built version to the powershell core and windows powershell paths, will remove any existing versions)
`choco upgrade fogapi -y`
For more information about FOG see

* Manual Method:
* download the zip of this repo and extract it and use Import-Module on the extracted path
- https://FOGProject.org
- https://docs.fogproject.org
- https://github.com/FOGProject
- https://github.com/FOGProject/fogproject
- https://forums.fogproject.org

The module is now installed.
You can use Set-fogserverSettings to set your fogserver hostname and api keys.
The first time you try to run a command the settings.json file will automatically open
in notepad on windows, nano on linux, or TextEdit on Mac
You can also open the settings.json file and edit it manually before running your first command.
The default settings are explanations of where to find the proper settings since json can''''t have comments
# Versioning

Once the settings are set you can have a jolly good time utilzing the fog documentation
found here https://news.fogproject.org/simplified-api-documentation/ that was used to model the parameters
The versioning of this module follows this pattern

i.e.
`{Year|Month}.{Major Version}.{Revision #}`

Get-FogObject has a type param that validates to object, objectactivetasktype, and search as those are the options given in the documentation.
Each of those types validates (which means autocompletion) to the core types listed in the documentation.
So if you typed in Get-FogObject -Type object -Object h and then started hitting tab, it would loop through the possible core objects you can get from the api that start with ''''h'''' such as history, host, etc.
## Year/Month

Unless you filter a get with a json body it will return all the results into a powershell object. That object is easy to work with to create other commands. Note: Full Pipeline support will come at a later time
i.e.
This versioning shows you first the Year and month this version of the module was published, giving you an idea of when it was last updated.
i.e. 2208 would be august 2022.

hosts = Get-FogObject -Type Object -CoreObject Host # calls GET on {your-fog-server}/fog/host to list all hosts
Now you can search all your hosts for the one or ones you''''re looking for with powershell
maybe you want to find all the hosts with ''''IT'''' in the name (note ''''?'''' is an alias for Where-Object)
ITHosts = hosts.hosts | ? name -match ''''IT'''';
## Major

Now maybe you want to change the image all of these computers use to one named ''''IT-Image''''
You can edit the object in powershell with a foreach-object (''''%'''' is an alias for foreach-object)
updatedITHosts = ITHosts | % { _.imagename = ''''IT-image''''}
The Major version follows the typical major versioning where any major changes will increment this version number, especially possible breaking changes or structural changes, etc.

Then you need to convert that object to json and pass each object into one api call at a time. Which sounds complicated, but it''''s not, it''''s as easy as

updateITHosts | % {
jsonData = _ | ConvertTo-Json;
Update-FogObject -Type object -CoreObject host -objectID _.id -jsonData jsonData;
#successful result of updated objects properties
#or any error messages will output to screen for each object
}

This is just one small example of the limitless things you can do with the api and powershell objects.
## Minor/Revision

see also the fogforum thread for the module https://forums.fogproject.org/topic/12026/powershell-api-module/2
'
Any time I publish a new version that isn''t a major change I''ll increment the revision. This may also be incremented for each build test and increment by more than one for each published version

# Usage

You can use Set-fogserverSettings to set your fogserver hostname and api keys.
The first time you try to run a command the settings.json file will automatically open
in notepad on windows, nano on linux, or TextEdit on Mac
You can also open the settings.json file and edit it manually before running your first command.
The default settings are explanations of where to find the proper settings since json can''''t have comments

Once the settings are set you can have a jolly good time utilzing the fog documentation
found here https://news.fogproject.org/simplified-api-documentation/ that was used to model the parameters

See https://github.com/darksidemilk/FogApi/blob/master/README.md for more examples and see https://fogapi.readthedocs.io/en/latest/commands/ for a list of all the commands

# Additional info

See also the fogforum thread for the module https://forums.fogproject.org/topic/12026/powershell-api-module/2
Full change log available at https://fogapi.readthedocs.io/en/latest/ReleaseNotes/
'

# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '3.0'
Expand Down Expand Up @@ -142,10 +141,11 @@ FunctionsToExport = 'Add-FogHostMac', 'Add-FogResultData', 'Approve-FogPendingMa
'New-FogObject', 'Receive-FogImage', 'Remove-FogObject',
'Remove-UsbMac', 'Repair-FogSnapinAssociations',
'Reset-HostEncryption', 'Resolve-HostID', 'Send-FogImage',
'Send-FogWolTask', 'Set-FogInventory', 'Set-FogServerSettings',
'Set-FogServerSettingsFileSecurity', 'Set-FogSetting',
'Set-FogSnapins', 'Set-WinToBootToPxe', 'Start-FogSnapin',
'Start-FogSnapins', 'Test-FogVerAbove1dot6', 'Update-FogObject'
'Send-FogWolTask', 'Set-FogHostImage', 'Set-FogInventory',
'Set-FogServerSettings', 'Set-FogServerSettingsFileSecurity',
'Set-FogSetting', 'Set-FogSnapins', 'Set-WinToBootToPxe',
'Start-FogSnapin', 'Start-FogSnapins', 'Test-FogVerAbove1dot6',
'Test-StringNotNullOrEmpty', 'Update-FogObject'

# 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.
CmdletsToExport = @()
Expand Down Expand Up @@ -173,13 +173,10 @@ AliasesToExport = 'Add-FogHost', 'Add-FogObject', 'Add-FogSnapins', 'Capture-Fog
# 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.
PrivateData = @{

#Title of this module
Title = 'FogApi'

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'fog','fogapi','imaging','provisioning','fogproject'
Tags = 'fog', 'fogapi', 'imaging', 'provisioning', 'fogproject'

# A URL to the license for this module.
LicenseUri = 'https://github.com/darksidemilk/FogApi/blob/master/LICENSE'
Expand All @@ -188,15 +185,15 @@ PrivateData = @{
ProjectUri = 'https://github.com/darksidemilk/FogApi'

# A URL to an icon representing this module.
IconUri = 'https://fogapi.readthedocs.io/en/latest/assets/favicon.png'
IconUri = 'https://cdn.statically.io/gh/darksidemilk/FogApi/0ed5e87e/FogApi/icons/favicon.png'

# ReleaseNotes of this module
ReleaseNotes = '
# 2409.9.4
# 2409.9.15

"Adding Chocolatey package and updates to auto adding various assets to each release. Also updated some manifest things. No Code changes, really just a maintenance release"
revert change of appending gpu ram

'
Full change log history available at https://fogapi.readthedocs.io/en/latest/ReleaseNotes/'

# Prerelease string of this module
# Prerelease = ''
Expand All @@ -209,6 +206,10 @@ PrivateData = @{

} # End of PSData hashtable


# Title
Title = 'FogApi'

} # End of PrivateData hashtable

# HelpInfo URI of this module
Expand Down
13 changes: 12 additions & 1 deletion FogApi/Public/Get-FogInventory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Get-FogInventory {
.PARAMETER hostObj
the host to get the model of the inventory object from
This is used for the inventory structure of the object
It defaults to the current host
It defx`aults to the current host

.PARAMETER fromFog
Switch param to simply return the currently set inventory of the fog host
Expand Down Expand Up @@ -58,6 +58,7 @@ function Get-FogInventory {
$cpu = Get-CimInstance -ClassName Win32_processor;
$bios = Get-CimInstance -ClassName Win32_Bios;
$hdd = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object DeviceID -match '0'; #get just drive 0 in case of multiple drives
$gpu = Get-CimInstance -ClassName Win32_VideoController | Where-Object name -notmatch 'Microsoft Remote Display Adapter'; #filter out rdp display adapter
$baseBoard = Get-CimInstance -ClassName Win32_BaseBoard;
$case = Get-CimInstance -ClassName Win32_SystemEnclosure;
$info = Get-ComputerInfo;
Expand Down Expand Up @@ -98,6 +99,16 @@ function Get-FogInventory {
$hostObj.inventory.caseserial = $case.SerialNumber;
$hostObj.inventory.caseasset = $case.SMBIOSAssetTag;
$hostObj.inventory.memory = "$([MATH]::Round($(($comp.TotalPhysicalMemory) / 1GB),2)) GiB";
if ($null -ne $hostObj.inventory.gpuvendors) {
$hostObj.inventory.gpuvendors = $gpu.AdapterCompatibility;
}
if ($null -ne $hostObj.inventory.gpuproducts) {
$hostObj.inventory.gpuproducts = $gpu.VideoProcessor
#below is an attempt to append the video memoery of each gpu, but it gave wrong values on some cards
<# $hostObj.inventory.gpuproducts = $gpu | Foreach-Object {
"$($_.VideoProcessor) - ($([math]::round($_.AdapterRAM/1GB))GB)";
} #>
}
$jsonData = $hostObj.inventory | ConvertTo-Json;
return $jsonData;
}
Expand Down
Loading