-
Notifications
You must be signed in to change notification settings - Fork 2
81 lines (75 loc) · 3.04 KB
/
publish.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
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Publish
on:
workflow_dispatch:
inputs:
release:
description: "Create a draft release?"
required: false
type: boolean
default: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Show Inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: |
dotnet restore --packages .nuget --runtime win-x64
- name: Extract Version from Project File
id: extract-version
shell: pwsh
run: |
$csprojPath = (Get-ChildItem -Path . -Recurse -Filter *.csproj).FullName
$version = [xml](Get-Content $csprojPath) | Select-Xml -XPath "//PropertyGroup/AssemblyVersion" | ForEach-Object { $_.Node.InnerXml }
if (-not $version) {
$version = [xml](Get-Content $csprojPath) | Select-Xml -XPath "//PropertyGroup/Version" | ForEach-Object { $_.Node.InnerXml }
}
$semver = $version -replace '(\d+\.\d+\.\d+)\.\d+', '$1' # Convert to semver by stripping the 4th part
$tag="v$semver"
echo "version = $version"
echo "semver = $semver"
echo "tag = $tag"
echo "version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "semver=$semver" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Display Version and Tag
shell: pwsh
run: |
$version = '${{ steps.extract-version.outputs.version }}'
$semver = '${{ steps.extract-version.outputs.semver }}'
$tag = '${{ steps.extract-version.outputs.tag }}'
Write-Host "Version: $version"
Write-Host "Semver: $semver"
Write-Host "Tag: $tag"
- name: Build
run: |
dotnet build --configuration Release --no-restore
- name: Publish
run: |
dotnet publish -c Release -r win-x64
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: "StarfieldSaveTool-${{ steps.extract-version.outputs.semver }}"
# A file, directory or wildcard pattern that describes what to upload
path: ${{ github.workspace }}/bin/Release/net8.0/win-x64/publish/**/*
# The desired behavior if no files are found using the provided path.
# if-no-files-found: # optional, default is warn
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ inputs.release == true }}
with:
files: ${{ github.workspace }}/bin/Release/net8.0/win-x64/publish/**/*
prerelease: true
draft: true
name: ${{ steps.extract-version.outputs.semver }}
tag_name: ${{ steps.extract-version.outputs.tag }}