Updated build.yml and create_release.yml #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version' | |
required: true | |
default: 'v0.0.1-alpha' | |
type: string | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
setup: | |
runs-on: windows-latest | |
permissions: | |
contents: write | |
outputs: | |
version: ${{ steps.validate-version.outputs.version }} | |
version-prefix: ${{ steps.validate-version.outputs.version-prefix }} | |
version-suffix: ${{ steps.validate-version.outputs.version-suffix }} | |
steps: | |
- id: validate-version | |
name: Validate Version | |
run: | | |
# if this is on a release tag push it will use the ref_name, otherwise on | |
# workflow_dispatch the version is required | |
$version = '${{ github.ref_name || inputs.version }}' | |
$version = $version.TrimStart('v') | |
Write-Host "Version: " -NoNewLine | |
Write-Host "$($PSStyle.Foreground.BrightCyan)$version$($PSStyle.Reset)" | |
if ([string]::IsNullOrEmpty($version)) { throw 'A release version was not specified.' } | |
# TODO: validate the version number format with regex | |
$parts = $version -split '-',2 | |
$prefix = $parts[0] | |
$suffix = $parts[1] | |
Write-Host "" | |
Write-Host "Prefix: " -NoNewLine | |
Write-Host "$($PSStyle.Foreground.BrightCyan)$prefix$($PSStyle.Reset)" | |
Write-Host "Suffix: " -NoNewLine | |
Write-Host "$($PSStyle.Foreground.BrightCyan)$suffix$($PSStyle.Reset)" | |
Write-Host "" | |
echo "version=version" >> $env:GITHUB_OUTPUT | |
echo "version-prefix=$prefix" >> $env:GITHUB_OUTPUT | |
echo "version-suffix=$suffix" >> $env:GITHUB_OUTPUT | |
build: | |
uses: syntax-tm/SteamAchievementManager/.github/workflows/build.yml@main | |
needs: setup | |
with: | |
is_release: true | |
version: ${{ needs.setup.outputs.version }} | |
create-release: | |
runs-on: windows-latest | |
needs: [build] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Create Archive | |
run: | | |
$items = Get-ChildItem artifacts | |
$items | % { Compress-Archive -Path "$($_.FullName)\*" -DestinationPath "$($_.FullName).zip" -Force } | |
Get-ChildItem -Path artifacts -Filter *.zip | Format-Table | |
- uses: ncipollo/release-action@v1 | |
with: | |
artifacts: artifacts/*.zip | |
bodyFile: ./CHANGELOG.md | |
draft: true | |
allowUpdates: true | |
artifactErrorsFailBuild: true |