-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (50 loc) · 2.14 KB
/
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
name: Release with Tag Version
on:
push:
tags:
- 'v*.*.*' # Match version tags like v1.0.0
jobs:
release:
runs-on: windows-latest # Use a Windows runner
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Extract version from tag
run: echo "VERSION=${GITHUB_REF_NAME#refs/tags/v}" >> $GITHUB_ENV
- name: Extract publish directory from profile
run: |
$publishProfilePath = "CsvConverter/Properties/PublishProfiles/FolderProfile.pubxml"
$publishDir = (Select-Xml -Path $publishProfilePath -XPath "//PublishDir").Node.InnerText
echo "PUBLISH_DIR=$publishDir" >> $GITHUB_ENV
shell: pwsh
- name: Update version in .csproj
run: |
echo "Updating version in .csproj to ${VERSION}"
powershell -Command "(Get-Content CsvConverter/CsvConverter.csproj) -replace '<Version>.*</Version>', '<Version>${VERSION}</Version>' | Set-Content CsvConverter/CsvConverter.csproj"
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Publish application using publish profile
run: dotnet publish CsvConverter/CsvConverter.csproj -c Release /p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml
- name: Verify publish output
run: |
if (!(Test-Path -Path "${{ env.PUBLISH_DIR }}")) {
Write-Error "Publish directory does not exist: ${{ env.PUBLISH_DIR }}"
exit 1
}
Write-Host "Publish directory found: ${{ env.PUBLISH_DIR }}"
- name: Archive published binaries
run: |
mkdir release
powershell Compress-Archive -Path "${{ env.PUBLISH_DIR }}\*" -DestinationPath "release\CsvConverter-${{ env.VERSION }}.zip"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false
files: release\CsvConverter-${{ env.VERSION }}.zip