-
Notifications
You must be signed in to change notification settings - Fork 13
147 lines (121 loc) · 4.66 KB
/
build.yml
File metadata and controls
147 lines (121 loc) · 4.66 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build and Release
on:
push:
branches:
- main
- develop
workflow_dispatch:
pull_request:
permissions:
contents: write
jobs:
versioning:
runs-on: windows-latest
outputs:
fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
semVer: ${{ steps.version_step.outputs.semVer }}
informationalVersion: ${{ steps.version_step.outputs.informationalVersion }}
preReleaseLabel: ${{ steps.version_step.outputs.preReleaseLabel }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all tags
run: |
git fetch --tags --force
git tag
- name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: '5.x'
- name: Determine Version
id: version_step
uses: gittools/actions/gitversion/execute@v3.0.0
build:
needs: versioning
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore NET-MusicAPI/NET-MusicAPI.csproj
- name: Build
run: |
dotnet build NET-MusicAPI/NET-MusicAPI.csproj -c Release --no-restore -p:Version=${{ needs.versioning.outputs.semVer }} -p:InformationalVersion=${{ needs.versioning.outputs.informationalVersion }} -p:FileVersion=${{ needs.versioning.outputs.semVer }}
- name: Create release package
run: |
mkdir release-package
Copy-Item -Path NET-MusicAPI/bin/Release/net10.0/* -Destination release-package/ -Recurse
Compress-Archive -Path release-package/* -DestinationPath NET-MusicAPI-v${{ needs.versioning.outputs.semVer }}.zip
- name: Upload release package
uses: actions/upload-artifact@v4
with:
name: net-musicapi-${{ needs.versioning.outputs.semVer }}
path: NET-MusicAPI-v${{ needs.versioning.outputs.semVer }}.zip
release:
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }}
needs: [versioning, build]
runs-on: ubuntu-latest
env:
TAG_NAME: v${{ needs.versioning.outputs.semVer }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create tag
run: |
TAG_NAME="${{ env.TAG_NAME }}"
MSG="Release v${{ needs.versioning.outputs.semVer }}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
echo "Tag already exists, skipping"
exit 0
fi
git tag -a "$TAG_NAME" -m "${MSG}"
git push origin "$TAG_NAME"
- name: Download release package
uses: actions/download-artifact@v4
with:
name: net-musicapi-${{ needs.versioning.outputs.semVer }}
path: ./release
- name: Get commit summary
id: commits
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"• %s (\`%h\`)" | head -c 900)
else
COMMITS=$(git log -10 --pretty=format:"• %s (\`%h\`)" | head -c 900)
fi
if [ -z "$COMMITS" ]; then
COMMITS="No commit information available"
fi
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
release/NET-MusicAPI-v${{ needs.versioning.outputs.semVer }}.zip
prerelease: ${{ needs.versioning.outputs.preReleaseLabel != '' }}
tag_name: ${{ env.TAG_NAME }}
name: ${{ github.ref == 'refs/heads/main' && format('Release v{0}', needs.versioning.outputs.semVer) || format('Pre-release v{0}', needs.versioning.outputs.semVer) }}
body: |
## 📦 Version ${{ needs.versioning.outputs.semVer }}
${{ github.ref == 'refs/heads/main' && '### ✨ Stable Release' || '### 🚀 Pre-release (Development Build)' }}
**📝 Recent Changes:**
${{ steps.commits.outputs.summary }}
---
**Download:**
- NET-MusicAPI-v${{ needs.versioning.outputs.semVer }}.zip