Skip to content

Build and Draft Release #16

Build and Draft Release

Build and Draft Release #16

# Purpose: Build, sign, and check a draft release
name: Build and Draft Release
on:
workflow_dispatch:
inputs:
# checkov:skip=CKV_GHA_7:Manual inputs are desired.
releaseName:
description: "Release Name"
required: true
type: string
version:
description: "Release Version (e.g., 1.2.4)"
required: true
type: string
runQuickCheck:
description: "Run a quick check of release"
required: false
type: boolean
default: true
permissions: read-all
jobs:
build-and-draft:
name: Build and Draft Release
runs-on: windows-latest
environment: Development
env:
RELEASE_VERSION: ${{ inputs.version }}
permissions:
id-token: write
contents: write
defaults:
run:
shell: powershell
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: repo
- name: Install Azure Signing Tool
run: |
dotnet --version
dotnet tool install --global AzureSignTool --version 5.0.0
# OIDC Login to Azure Public Cloud with AzPowershell (enableAzPSSession true)
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Get Key Vault info
id: key-vault-info
env:
KEY_VAULT_INFO: ${{ secrets.SCUBA_KEY_VAULT_PROD}}
run: |
$KeyVaultInfo = ${env:KEY_VAULT_INFO} | ConvertFrom-Json
echo "KeyVaultUrl=$($KeyVaultInfo.KeyVault.URL)" >> $env:GITHUB_OUTPUT
echo "KeyVaultCertificateName=$($KeyVaultInfo.KeyVault.CertificateName)" >> $env:GITHUB_OUTPUT
- name: Sign Module
run: |
# Source the deploy utilities so the functions in it can be called.
. repo/utils/workflow/Publish-ScubaGear.ps1
# Remove non-release files
Remove-Item -Recurse -Force repo -Include .git*
Write-Output "Creating an array of the files to sign..."
$ArrayOfFilePaths = New-ArrayOfFilePaths `
-ModuleDestinationPath repo
Write-Output "Creating a file with a list of the files to sign..."
$FileListFileName = New-FileList `
-ArrayOfFilePaths $ArrayOfFilePaths
Write-Output "Calling AzureSignTool function to sign scripts, manifest, and modules..."
$AzureKeyVaultUrl = '${{ steps.key-vault-info.outputs.KeyVaultUrl }}'
$CertificateName = '${{ steps.key-vault-info.outputs.KeyVaultCertificateName }}'
Use-AzureSignTool `
-AzureKeyVaultUrl $AzureKeyVaultUrl `
-CertificateName $CertificateName `
-FileList $FileListFileName
Move-Item -Path repo -Destination "ScubaGear-${env:RELEASE_VERSION}" -Force
Compress-Archive -Path "ScubaGear-${env:RELEASE_VERSION}" -DestinationPath "ScubaGear-${env:RELEASE_VERSION}.zip"
- name: Create Release
uses: softprops/action-gh-release@v1
id: create-release
with:
draft: true
prerelease: false
name: ${{ inputs.releaseName }}
tag_name: v${{ inputs.version }}
files: ScubaGear-${{ inputs.version }}.zip
generate_release_notes: true
fail_on_unmatched_files: true
- name: Download Release
uses: dsaltares/[email protected]
if: ${{ inputs.runQuickCheck }}
with:
version: ${{ steps.create-release.outputs.id}}
file: "ScubaGear-${{ inputs.version }}.zip"
- name: Quick Check Release
if: ${{ inputs.runQuickCheck }}
run: |
Expand-Archive -Path "ScubaGear-${{ inputs.version }}.zip"
Get-ChildItem
Set-Location -Path "ScubaGear-${{ inputs.version }}"
Import-Module -Name .\PowerShell\ScubaGear\ScubaGear.psd1
Invoke-SCuBA -Version