1+ name : Publish C# Project
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ tags :
8+ - ' v*'
9+
10+ jobs :
11+ build_publish :
12+ runs-on : windows-latest
13+
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+
18+ - name : Setup .NET
19+ uses : actions/setup-dotnet@v4
20+ with :
21+ dotnet-version : " 8.0.x"
22+
23+ - name : Publish project
24+ run : dotnet publish DesktopICO.csproj --configuration Release --output ./bin/publish
25+
26+ - name : Get tag description
27+ id : tag_description
28+ run : |
29+ TAG_DESCRIPTION=$(git tag -l --format='%(contents)' ${{ github.ref_name }})
30+ echo "tag_description=${TAG_DESCRIPTION}" >> $GITHUB_OUTPUT
31+ shell : bash
32+
33+ - name : Get latest commit message
34+ id : commit_message
35+ run : |
36+ COMMIT_MESSAGE=$(git log -1 --pretty=%B)
37+ echo "commit_message=${COMMIT_MESSAGE}" >> $GITHUB_OUTPUT
38+ shell : bash
39+
40+ - name : Check existing release
41+ id : check_release
42+ run : |
43+ try {
44+ gh release view ${{ github.ref_name }} || true
45+ echo "release_exists=true" >> $env:GITHUB_OUTPUT
46+ } catch {
47+ echo "release_exists=false" >> $env:GITHUB_OUTPUT
48+ }
49+ shell : pwsh
50+ env :
51+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52+
53+ - name : Delete existing release
54+ run : |
55+ if (${{ steps.check_release.outputs.release_exists }} -eq 'true') {
56+ gh release delete ${{ github.ref_name }}
57+ }
58+ env :
59+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60+
61+ - name : Create Release
62+ env :
63+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
64+ run : |
65+ gh release create ${{ github.ref_name }} \
66+ --title "${{ github.ref_name }} ${{ steps.tag_description.outputs.tag_description }}" \
67+ --notes "Release for ${{ github.ref_name }}
68+
69+ Changes in this release :
70+ ${{ steps.commit_message.outputs.commit_message }}" \
71+ --draft=false \
72+ ./bin/publish/*.exe
73+ shell : bash
0 commit comments