forked from gibbed/SteamAchievementManager
-
-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (74 loc) · 2.56 KB
/
create_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Create Release
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: [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
$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