Skip to content

Commit 8e30690

Browse files
authored
Merge pull request #77 from bpedziwiatr/feature/32_auto_deployment
feat: Refactor CI workflows and enhance README documentation #32
2 parents 5f59d16 + b4955d9 commit 8e30690

7 files changed

Lines changed: 332 additions & 115 deletions

File tree

‎.github/pull_request_template.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Summary
2+
3+
- What changed?
4+
- Why is it needed?
5+
6+
## Commit Message
7+
8+
- Use a Conventional Commit prefix in the branch's commits:
9+
- `feat:` for new features
10+
- `fix:` for bug fixes
11+
- `refactor:`, `perf:`, `docs:`, `test:`, `ci:`, `build:`, `chore:`, `style:` for changes that should appear under `Changed`
12+
- `remove:`, `delete:`, `drop:` for removals
13+
- `sec:`, `security:` for security-related changes
14+
15+
## Verification
16+
17+
- [ ] `dotnet test DataverseGen.sln`
18+
- [ ] Release workflow impact checked, if applicable
19+
20+
## Release Notes
21+
22+
- [ ] This change is ready to appear in Keep a Changelog sections
23+
- [ ] Commit titles are specific enough to map cleanly to `Added`, `Changed`, `Fixed`, `Removed`, or `Security`

‎.github/workflows/main.yml‎

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎.github/workflows/release.yml‎

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- "release/**"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
package-and-pr:
15+
runs-on: windows-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: 7.0.x
27+
28+
- name: Install GitVersion tool
29+
shell: pwsh
30+
run: dotnet tool install --global GitVersion.Tool --version 5.12.0
31+
32+
- name: Add dotnet tools to PATH
33+
shell: pwsh
34+
run: echo "$env:USERPROFILE\.dotnet\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
35+
36+
- name: Build release packages
37+
shell: pwsh
38+
run: .\build.ps1
39+
40+
- name: Upload release artifacts
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: release-packages-${{ github.ref_name }}
44+
path: publish/*.zip
45+
if-no-files-found: error
46+
47+
- name: Prepare release metadata
48+
id: release_meta
49+
shell: pwsh
50+
run: |
51+
$gitv = dotnet-gitversion | ConvertFrom-Json -ErrorAction Stop
52+
$tag = "v$($gitv.NuGetVersionV2)"
53+
$title = "Release $tag"
54+
$notesPath = Join-Path $env:GITHUB_WORKSPACE 'release-notes.md'
55+
$previousTag = git describe --tags --abbrev=0 --match "v*" 2>$null
56+
$commitRange = if ($previousTag) { "$previousTag..HEAD" } else { "HEAD" }
57+
$releaseDate = (Get-Date).ToString('yyyy-MM-dd')
58+
$compareUrl = if ($previousTag) {
59+
"https://github.com/${{ github.repository }}/compare/$previousTag...$tag"
60+
}
61+
else {
62+
"https://github.com/${{ github.repository }}/commits/$tag"
63+
}
64+
65+
$commits = if ($previousTag) {
66+
git log $commitRange --no-merges --reverse --pretty=format:"%s%x09%h"
67+
}
68+
else {
69+
git log --no-merges --reverse --pretty=format:"%s%x09%h"
70+
}
71+
72+
$buckets = @{
73+
Added = New-Object System.Collections.Generic.List[string]
74+
Changed = New-Object System.Collections.Generic.List[string]
75+
Fixed = New-Object System.Collections.Generic.List[string]
76+
Removed = New-Object System.Collections.Generic.List[string]
77+
Security = New-Object System.Collections.Generic.List[string]
78+
}
79+
80+
foreach ($line in $commits) {
81+
if ([string]::IsNullOrWhiteSpace($line)) {
82+
continue
83+
}
84+
85+
$parts = $line -split "`t", 2
86+
$subject = $parts[0].Trim()
87+
$hash = if ($parts.Count -gt 1) { $parts[1].Trim() } else { '' }
88+
$entry = if ($hash) { "- $subject ($hash)" } else { "- $subject" }
89+
90+
switch -Regex ($subject) {
91+
'^(feat|add)(\([^)]+\))?:\s+' { $buckets.Added.Add($entry); continue }
92+
'^(fix)(\([^)]+\))?:\s+' { $buckets.Fixed.Add($entry); continue }
93+
'^(remove|delete|drop)(\([^)]+\))?:\s+' { $buckets.Removed.Add($entry); continue }
94+
'^(sec|security)(\([^)]+\))?:\s+' { $buckets.Security.Add($entry); continue }
95+
'^(refactor|perf|docs|test|ci|build|chore|style)(\([^)]+\))?:\s+' { $buckets.Changed.Add($entry); continue }
96+
default { $buckets.Changed.Add($entry); continue }
97+
}
98+
}
99+
100+
$sectionLines = New-Object System.Collections.Generic.List[string]
101+
102+
foreach ($sectionName in @('Added', 'Changed', 'Fixed', 'Removed', 'Security')) {
103+
if ($buckets[$sectionName].Count -gt 0) {
104+
$sectionLines.Add("### $sectionName")
105+
$sectionLines.Add('')
106+
$sectionLines.AddRange($buckets[$sectionName])
107+
$sectionLines.Add('')
108+
}
109+
}
110+
111+
if ($sectionLines.Count -eq 0) {
112+
$sectionLines.Add('### Changed')
113+
$sectionLines.Add('')
114+
$sectionLines.Add('- No notable changes were detected for this release.')
115+
$sectionLines.Add('')
116+
}
117+
118+
$releaseNotes = @(
119+
'# Release Notes'
120+
''
121+
"## [$tag] - $releaseDate"
122+
''
123+
'### Summary'
124+
''
125+
"- Release branch: `$env:GITHUB_REF_NAME`"
126+
"- Version: `$($gitv.FullSemVer)`"
127+
"- SemVer: `$($gitv.SemVer)`"
128+
"- NuGetVersion: `$($gitv.NuGetVersionV2)`"
129+
"- Commit: `$($gitv.Sha)`"
130+
"- Base tag: `$($previousTag ?? 'none')`"
131+
"- Commit range: `$commitRange`"
132+
"- Compare: [$compareUrl]($compareUrl)"
133+
''
134+
) + $sectionLines + @(
135+
''
136+
'## Packages'
137+
''
138+
"- `DataverseGen-CLI_includedotnet_$($gitv.NuGetVersionV2).zip`"
139+
"- `DataverseGen-CLI_nodotnet_$($gitv.NuGetVersionV2).zip`"
140+
)
141+
142+
$releaseNotes | Set-Content -Path $notesPath -Encoding utf8
143+
144+
"tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
145+
"title=$title" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
146+
"notes_path=$notesPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
147+
148+
- name: Check for existing pull request
149+
id: pr_check
150+
shell: pwsh
151+
env:
152+
GH_TOKEN: ${{ github.token }}
153+
run: |
154+
$prs = gh pr list --head $env:GITHUB_REF_NAME --base main --state open --json number | ConvertFrom-Json
155+
$exists = ($prs | Measure-Object).Count -gt 0
156+
"exists=$exists" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
157+
158+
- name: Create pull request to main
159+
if: steps.pr_check.outputs.exists != 'true'
160+
shell: pwsh
161+
env:
162+
GH_TOKEN: ${{ github.token }}
163+
run: |
164+
gh pr create `
165+
--base main `
166+
--head $env:GITHUB_REF_NAME `
167+
--title "${{ steps.release_meta.outputs.title }}" `
168+
--body-file "${{ steps.release_meta.outputs.notes_path }}"
169+
170+
- name: Publish GitHub release
171+
shell: pwsh
172+
env:
173+
GH_TOKEN: ${{ github.token }}
174+
run: |
175+
$tag = "${{ steps.release_meta.outputs.tag }}"
176+
$title = "${{ steps.release_meta.outputs.title }}"
177+
$notesPath = "${{ steps.release_meta.outputs.notes_path }}"
178+
$releaseExists = $false
179+
180+
gh release view $tag --json tagName | Out-Null
181+
if ($LASTEXITCODE -eq 0) {
182+
$releaseExists = $true
183+
}
184+
185+
if ($releaseExists) {
186+
gh release edit $tag --title $title --notes-file $notesPath
187+
gh release upload $tag publish/*.zip --clobber
188+
}
189+
else {
190+
gh release create $tag publish/*.zip --title $title --notes-file $notesPath --target $env:GITHUB_SHA
191+
}

‎.github/workflows/testing.yml‎

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,29 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: Tests
22

3-
name: Testing-fun
4-
5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the develop branch
8-
push:
9-
branches: [ develop ]
104
pull_request:
11-
branches: [ develop ]
12-
13-
# Allows you to run this workflow manually from the Actions tab
5+
branches:
6+
- develop
7+
push:
8+
branches:
9+
- develop
1410
workflow_dispatch:
1511

16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1712
jobs:
18-
# This workflow contains a single job called "build"
19-
build:
20-
# The type of runner that the job will run on
13+
test:
2114
runs-on: windows-latest
22-
env:
23-
SolutionPath: DataverseGen.sln
24-
PackageName: ''
2515

26-
# Steps represent a sequence of tasks that will be executed as part of the job
2716
steps:
28-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29-
# - uses: actions/checkout@v2
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: 7.0.x
3024

31-
# Runs a single command using the runners shell
32-
- name: Run a one-line script
33-
run: echo Hello, world!
34-
- name: Deploy ARM template
35-
run: |
36-
$output = "aabs"
37-
$armOutputObj = "2345"
38-
39-
$webAppName = $output + "_add_"+ $armOutputObj
40-
echo "PackageName=$webAppName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
41-
shell: pwsh
42-
25+
- name: Restore
26+
run: dotnet restore DataverseGen.sln
4327

44-
# Runs a set of commands using the runners shell
45-
- name: Run a multi-line script
46-
run: |
47-
echo $PackageName
48-
echo $SolutionPath
49-
28+
- name: Test
29+
run: dotnet test DataverseGen.sln --configuration Release --no-restore

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,5 @@ healthchecksdb
347347
MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350-
.ionide/
350+
.ionide/
351+
AGENT.md

‎.gitmessage.txt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
feat: short summary
2+
3+
# Type one of:
4+
# feat, fix, refactor, perf, docs, test, ci, build, chore, style, remove, delete, drop, sec, security
5+
#
6+
# Examples:
7+
# feat(cli): add release package upload
8+
# fix(core): handle empty entity list
9+
#
10+
# Keep the subject short, imperative, and specific.
11+
# Use the body only when the change needs context, risk notes, or follow-up items.

0 commit comments

Comments
 (0)