Skip to content

Publish-CosmosLite

Publish-CosmosLite #33

name: Publish-CosmosLite
on:
push:
branches:
- master
paths-ignore:
- '**'
tags:
- 'v*'
workflow_dispatch:
jobs:
# This workflow contains a single job called "publishToGallery"
publishToGallery:
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
uses: actions/checkout@v2
- name: Build
shell: pwsh
run: |
Copy-Item -Path "$env:GITHUB_WORKSPACE\LICENSE" -Destination "$env:GITHUB_WORKSPACE\Module\CosmosLite\LICENSE.txt" -Force
&"$env:GITHUB_WORKSPACE\Commands\BuildModule.ps1" -RootPath "$env:GITHUB_WORKSPACE"
- name: Install prerequisites
shell: pwsh
run: |
Install-Module AadAuthenticationFactory -AllowPrerelease -Force -Scope CurrentUser -Verbose
- name: Install AzureSignTool
shell: pwsh
run: |
dotnet tool install --global AzureSignTool
- name: Sign files
shell: pwsh
run: |
$files = Get-ChildItem "$env:GITHUB_WORKSPACE\Module" -File -Recurse -Include *.ps1, *.ps1xml, *.psd1, *.psm1, *.pssc, *.psrc, *.cdxml
try {
foreach ($file in $files) {
azuresigntool sign `
-kvu ${{ vars.CODESIGNING_KEYVAULTURI }} `
-kvi ${{ vars.TENANTINTEGRATION_CLIENTID }} `
-kvt ${{ vars.TENANTINTEGRATION_TENANTID }} `
-kvs ${{ secrets.TENANTINTEGRATION_CLIENTSECRET }} `
-kvc ${{ vars.CODESIGNING_CERTNAME }} `
-tr 'http://timestamp.digicert.com' `
-v "$($file.FullName)"
}
}
catch {
Write-Host "Error: $($_.Exception)"
throw
}
Write-Host "Signed files summary:"
Get-AuthenticodeSignature -FilePath $files
- name: Publish
#Publish to PS Gallery
if: ${{ github.event_name != 'workflow_dispatch' }}
shell: pwsh
env:
SECRET: ${{ secrets.PSGallery_APIKey }}
run: |
write-host "Publishing from: $env:GITHUB_WORKSPACE\Module\CosmosLite"
try
{
#setup PSModulePath
$env:PSModulePath = "$env:PSModulePath;$env:GITHUB_WORKSPACE\Module"
"PSModulePath: $env:PSModulePath"
Publish-Module -Path "$env:GITHUB_WORKSPACE\Module\CosmosLite" -NuGetApiKey "$env:SECRET"
}
catch
{
Write-Host "Error: $($_.Exception)"
throw
}