Skip to content

Merge pull request #115 from IntelliTect/AddChatGptModle #40

Merge pull request #115 from IntelliTect/AddChatGptModle

Merge pull request #115 from IntelliTect/AddChatGptModle #40

Workflow file for this run

name: Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
defaults:
run:
shell: pwsh
jobs:
Deploy:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Discover Changes
run: |
$changedModules = $(git diff --name-only HEAD HEAD~)
$changedModules
$files = $changedModules -split ' ' | ForEach-Object{[System.IO.FileInfo] $_}
$modules = @()
foreach ($file in $files)
{
if((Test-Path $file.FullName)){
$fileDirectoryParent = $file.Directory.Parent
if ($fileDirectoryParent -and $fileDirectoryParent.Name -eq "Modules") {
$modules += $file.Directory
}
}
}
$modules.Length
if($modules.Length -eq 0){
exit
}
$changedModulesPath = mkdir -Name "StagingChangedModules\" -Force
For ($i=0; $i -lt $modules.Length; $i++)
{
$module = $modules[$i]
Copy-Item -Path $module.FullName -Destination $changedModulesPath -Recurse -Force
}
- name: Update Changed Modules
run: |
if(!(Test-Path StagingChangedModules)) {
Write-Host "No modules changed"
exit
}
$moduleFolders = Get-ChildItem StagingChangedModules
foreach ($item in $moduleFolders){
$moduleName = $item.Name
$manifest = Get-ChildItem $item.PSPath | Where-Object{$_.Name -like "*psd1"}
if(!$manifest){
Write-Error "The manifest for $moduleName was not found"
}
$content = Get-Content $manifest.PSPath | ForEach-Object{
$_
if ($_ -match "ModuleVersion"){
$version = [System.Version]($_ -split "'")[1]
}
}
$major = 0
$minor = 0
$build = 0
$minorRev = 1
if($version.Major -gt 0){$major = $version.Major}
if($version.Minor -gt 0){$minor = $version.Minor}
if($version.Build -gt 0){$build = $version.Build}
if($version.MinorRevision -gt 0){$minorRev = $version.MinorRevision + 1}
$updatedVersion = New-Object -TypeName system.Version -ArgumentList $major, $minor, $build, $minorRev
$PushPath = ".\Modules\" +($manifest.PSChildName).Substring(0, $manifest.PSChildName.length - 5 ) + "\"+ ($manifest.PSChildName)
$PublishPath = ".\StagingChangedModules\" +($manifest.PSChildName).Substring(0, $manifest.PSChildName.length - 5 ) + "\"+ ($manifest.PSChildName)
Update-ModuleManifest -Path $PushPath -ModuleVersion $updatedVersion
Update-ModuleManifest -Path $PublishPath -ModuleVersion $updatedVersion
Write-Host "$moduleName's version was updated from $version to $updatedVersion"
}
- name: Push Changes
run: |
if(!(Test-Path StagingChangedModules)) {
Write-Host "No modules changed"
exit
}
git config --global user.email "[email protected]"
git config --global user.name "worseTyler"
git add Modules/\*.psd1
git commit -m "[skip ci] Commit from build agent"
git push
- name: Publish To Gallery
run: |
if(!(Test-Path StagingChangedModules)) {
Write-Host "No modules changed"
Write-Host "Nothing to Publish"
exit
}
$moduleFolders = Get-ChildItem StagingChangedModules
foreach ($item in $moduleFolders){
Publish-Module -Path $item.FullName -NuGetApiKey ${{ secrets.POWERSHELL_GALLERY_API_KEY }} -Verbose
}