This repository was archived by the owner on Jan 25, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 33
84 lines (73 loc) · 2.74 KB
/
deploy.yml
File metadata and controls
84 lines (73 loc) · 2.74 KB
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
name: Build and Publish Release
on:
workflow_dispatch:
jobs:
build_and_release:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Extract version and changelog
run: |
$content = Get-Content -Path './CHANGELOG' -Raw # Updated path
$matches = [Regex]::Matches($content, '--\s+(\d{4}\.\d{2}\.\d{2})\s+-\s+V([^\s]+)\r?\n\r?\n(-\s+[^-]+(?:\r?\n-.*?)*)(?=\r?\n--|\z)', 'Singleline')
$latest = $matches[0]
$version = $latest.Groups[2].Value
$changelog = $latest.Groups[3].Value.Trim()
echo "VERSION=$version" >> $GITHUB_ENV
echo "::set-output name=version::$version"
echo "::set-output name=changelog::$changelog"
- name: Get existing tags
id: get_tags
run: |
git fetch --tags
$tags = git tag
echo "::set-output name=tags::$tags"
- name: Set new tag
id: set_tag
run: |
$baseTag = "v${{ steps.extract_info.outputs.version }}"
$tags = "${{ steps.get_tags.outputs.tags }}"
$count = 0
while ($tags -contains "$baseTag-$count") {
$count++
}
if ($tags -contains $baseTag) {
$newTag = "$baseTag-$count"
} else {
$newTag = $baseTag
}
echo "New tag: $newTag"
echo "::set-output name=new_tag::$newTag"
echo "NewTag=$newTag" >> $GITHUB_ENV
- name: Build Project
run: dotnet build --configuration Release
- name: Publish Project
run: dotnet publish --configuration Release --output ./publish
- name: Zip Publish Folder
run: |
Compress-Archive -Path ./publish/* -DestinationPath ./publish/${{ github.repository }}.zip
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.set_tag.outputs.new_tag }}
release_name: ${{ github.repository }} ${{ steps.set_tag.outputs.new_tag }}
body: ${{ steps.extract_info.outputs.changelog }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/${{ github.repository }}.zip
asset_name: ${{ github.repository }}-${{ steps.set_tag.outputs.new_tag }}.zip
asset_content_type: application/zip