v0.7.0-beta by syntax-tm #34
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 | |
run-name: ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.ref_name }} by ${{ github.actor }} | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version' | |
required: true | |
default: 'v0.0.1' | |
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 "Prefix: " -NoNewLine | |
Write-Host "$($PSStyle.Foreground.BrightCyan)$prefix$($PSStyle.Reset)" | |
Write-Host "Suffix: " -NoNewLine | |
Write-Host "$($PSStyle.Foreground.BrightCyan)$suffix$($PSStyle.Reset)" | |
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: [setup, build] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
# name: ${{ env.artifact-name }} | |
env: | |
artifact-name: ${{ needs.build.outputs.artifact-name }} | |
- name: Create Archive | |
run: | | |
$items = Get-ChildItem artifacts | |
$artifactName = "SAM_${{ needs.setup.outputs.version }}" | |
Write-Host "Artifacts:" | |
foreach ($item in $items) | |
{ | |
Write-Host "- $($PSStyle.Foreground.BrightCyan)$($item.Name)$($PSStyle.Reset)" | |
} | |
$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 |