ExcelCoordinate.build.ps1

using namespace System.IO

[string] $Here = [Path]::GetDirectoryName($PSCommandPath)

Set-StrictMode -Version 3.0

task execute_ExcelCoordinate {
    ConvertFrom-ExcelCellCoordinate -i 'A1'
}

task Test {
    $filesToCover = @(
        ([System.IO.Path]::Join($Here, 'cp-21nhi.ExcelCoordinate.ps1'))
    )
    $filesToAnalyze = @(
        ([System.IO.Path]::Join($Here, 'cp-21nhi.ExcelCoordinate.ps1')),
        ([System.IO.Path]::Join($Here, 'cp-21nhi.ExcelCoordinate.psd1')),
        ([System.IO.Path]::Join($Here, 'cp-21nhi.ExcelCoordinate.psm1')),
        ([System.IO.Path]::Join($Here, 'ExcelCoordinate.Tests.ps1'))
    )
    $filesToAnalyze

    Import-Module -Name Pester

    $config = New-PesterConfiguration
    $config.Run.Path = $filesToCover
    $config.CodeCoverage.Enabled = $true
    $config.CodeCoverage.path = $filesToCover
    $config.CodeCoverage.CoveragePercentTarget = 80
    $config.CodeCoverage.OutPutFormat = 'CoverageGutters'
    $config.CodeCoverage.OutPutPath = 'cov.xml'
    $config.CodeCoverage.OutPutEncoding = 'UTF-8'
    $config.Run.path = "$Here\ExcelCoordinate.Tests.ps1"

    Invoke-Pester -Configuration $config


    Import-Module PSScriptAnalyzer

    foreach ($file in $filesToAnalyze) {
        Invoke-ScriptAnalyzer -Path $file
    }
}

task Release {
    if (Test-Path ".env" -PathType Leaf) {
        Get-Content .env | ForEach-Object {
            $name, $value = $_.Split('=')
            Set-Content env:\$name $value
        }
    }

    [string] $manifestFilePath = ([System.IO.path]::Join($Here, 'cp-21nhi.ExcelCoordinate.psd1'))

    [version] $currentVersion = (Find-Module -Name 'cp-21nhi.ExcelCoordinate' -Repository PSGallery).version

    $newVersion = [version]::new($currentVersion.Major, $currentVersion.Minor, $currentVersion.Build + 1)

    $Params = @{
        Path = $manifestFilePath
        ModuleVersion = $newVersion
    }

    Update-ModuleManifest @Params

    Write-Host 'API_KEY' $Env:PSGALLERY_API_KEY

    Publish-PSResource -Path $manifestFilePath -Repository PSGallery -ApiKey $Env:PSGALLERY_API_KEY
}

task . Test, Release