-
-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build/better release description (#2256)
- Loading branch information
Showing
3 changed files
with
302 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ jobs: | |
nkdAgility_Ring: ${{ steps.nkdagility.outputs.Ring }} | ||
nkdAgility_WingetApplicationId: ${{ steps.nkdagility.outputs.WingetApplicationId }} | ||
nkdAgility_IsBuildEditBranch: ${{ steps.nkdagility.outputs.IsBuildEditBranch }} | ||
nkdAgility_ReleaseDescription: ${{ steps.nkdagility.outputs.release_description }} | ||
nkdAgility_ReleaseDescriptionState: ${{ steps.nkdagility.outputs.release_description_state }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -56,6 +58,11 @@ jobs: | |
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
useConfigFile: true | ||
- uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }} | ||
private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }} | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
|
@@ -70,6 +77,8 @@ jobs: | |
- name: "Build NKDAgility Outputs" | ||
shell: pwsh | ||
id: nkdagility | ||
env: | ||
GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
run: | | ||
$Ring = "Canary" | ||
$WingetApplicationId = "nkdagility.azure-devops-migration-tools" | ||
|
@@ -97,7 +106,28 @@ jobs: | |
$IsBuildEditBranch = $true; | ||
} | ||
Write-Output "IsBuildEditBranch=$IsBuildEditBranch" | ||
echo "IsBuildEditBranch=$IsBuildEditBranch" >> $env:GITHUB_OUTPUT | ||
echo "IsBuildEditBranch=$IsBuildEditBranch" >> $env:GITHUB_OUTPUT | ||
Write-Output "Running Get-ReleaseDescription.ps1" | ||
. .\build\include\Get-ReleaseDescription.ps1 | ||
$description = Get-ReleaseDescription -mode log -OPEN_AI_KEY ${{ secrets.OPENAI_API_KEY }} | ||
if ($description -eq $null) { | ||
$description = "No release description found"; | ||
echo "release_description_state=false" >> $env:GITHUB_OUTPUT | ||
} else { | ||
echo "release_description_state=true" >> $env:GITHUB_OUTPUT | ||
} | ||
$EOF = -join (1..15 | ForEach {[char]((48..57)+(65..90)+(97..122) | Get-Random)}) | ||
echo "release_description<<$EOF" >> $env:GITHUB_OUTPUT | ||
echo $description >> $env:GITHUB_OUTPUT | ||
echo "$EOF" >> $env:GITHUB_OUTPUT | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: AzureDevOpsMigrationTools-Scripts | ||
path: ./build/** | ||
|
||
# Setup Validator | ||
SetupSummeryStage: | ||
|
@@ -116,6 +146,8 @@ jobs: | |
- nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}} | ||
- nkdAgility_IsBuildEditBranch: ${{needs.Setup.outputs.nkdAgility_IsBuildEditBranch}} | ||
- nkdAgility_WingetApplicationId: ${{needs.Setup.outputs.nkdAgility_WingetApplicationId}} | ||
- nkdAgility_ReleaseDescriptionState: ${{needs.Setup.outputs.nkdAgility_ReleaseDescriptionState}} | ||
### GitVersion | ||
- GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}} | ||
- GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}} | ||
|
@@ -127,6 +159,8 @@ jobs: | |
- HasChanged_src: ${{needs.Setup.outputs.HasChanged_src}} | ||
- HasChanged_docs: ${{needs.Setup.outputs.HasChanged_docs}} | ||
- HasChanged_automation: ${{needs.Setup.outputs.HasChanged_automation}} | ||
## nkdAgility_ReleaseDescription | ||
${{needs.Setup.outputs.nkdAgility_ReleaseDescription}} | ||
"@ | ||
echo $markdown >> $Env:GITHUB_STEP_SUMMARY | ||
|
@@ -162,10 +196,6 @@ jobs: | |
files: '["**/StaticVariables.cs"]' | ||
tokenPrefix: "${" | ||
tokenSuffix: "}" | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: AzureDevOpsMigrationTools-BuildScripts | ||
path: ./build/** | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
|
@@ -265,6 +295,10 @@ jobs: | |
- uses: actions/download-artifact@v4 | ||
with: | ||
name: AzureDevOpsMigrationTools-Packages | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: AzureDevOpsMigrationTools-Scripts | ||
path: ./build/ | ||
- uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
|
@@ -281,6 +315,9 @@ jobs: | |
if ($Env:nkdAgility_Ring -eq 'Release') { | ||
echo "discussion_category_name=Anouncement" >> $env:GITHUB_OUTPUT | ||
} | ||
. .\build\include\Get-ReleaseDescription.ps1 | ||
$description = Get-ReleaseDescription -mode log -OPEN_AI_KEY ${{ secrets.OPENAI_API_KEY }} | ||
echo "release_description=$description" >> $env:GITHUB_OUTPUT | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
|
@@ -301,6 +338,8 @@ jobs: | |
Version: ${{ needs.Setup.outputs.GitVersion_SemVer }} | ||
Ring: (${{ needs.Setup.outputs.nkdAgility_Ring }}) | ||
${{ needs.Setup.outputs.nkdAgility_ReleaseDescription }} | ||
## Get the tools | ||
- Download the [MigrationTools-${{ needs.Setup.outputs.GitVersion_SemVer }}.zip](https://github.com/nkdAgility/azure-devops-migration-tools/releases/download/v${{ needs.Setup.outputs.GitVersion_SemVer }}/MigrationTools-${{ needs.Setup.outputs.GitVersion_SemVer }}.zip) file below | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
<# | ||
Script description. | ||
Some notes. | ||
#> | ||
# Helpers | ||
enum ExecutionMode { | ||
log = 0 | ||
diff = 1 | ||
} | ||
|
||
# Define Parameters | ||
function Get-ReleaseDescription { | ||
param ( | ||
|
||
[Parameter(Mandatory=$false)] | ||
[string]$compairFrom, | ||
|
||
# name of the output folder | ||
[Parameter(Mandatory=$false)] | ||
[string]$compairTo, | ||
|
||
# name of the output folder | ||
[Parameter(Mandatory=$true)] | ||
[ExecutionMode]$mode, | ||
|
||
# name of the output folder | ||
[Parameter(Mandatory=$true)] | ||
[string]$OPEN_AI_KEY | ||
) | ||
Write-Host "=========================================" | ||
Write-Host "Azure DevOps Migration Tools (Release) Description" | ||
Write-Host "=========================================" | ||
Write-Host "Mode: $mode" | ||
if ([string]::IsNullOrEmpty($compairFrom) ){ | ||
$lastRelease = gh release list --exclude-pre-releases --json name,tagName,publishedAt --limit 1 | ConvertFrom-Json | ||
$compairFrom = $lastRelease.tagName | ||
} | ||
If ([string]::IsNullOrEmpty($compairTo) ) { | ||
$compairTo = "main" | ||
} | ||
Write-Host "Comparing: $compairFrom...$compairTo" | ||
Write-Host "-----------------------------------------" | ||
switch ($mode) | ||
{ | ||
"log" { | ||
Write-Host "Running: git log" | ||
$result = git log --pretty=format:'{\"hash\": \"%H\", \"author\": \"%an\", \"date\": \"%ad\", \"message\": \"%s\"}' "$compairFrom...$compairTo" # | ||
Write-Host "Complete: git log" | ||
} | ||
"diff" { | ||
Write-Host "Running: git diff" | ||
$diffOutPut = git diff "$compairFrom...$compairTo" | ||
$joineddiffOutPut = $diffOutPut -join "`n" | ||
$splitdiffOutPut = $joineddiffOutPut -split "diff --git" | ||
$result = $splitdiffOutPut | ConvertTo-Json | ||
Write-Host "Complete: git diff" | ||
} | ||
default { | ||
Write-Host "Invalid mode" | ||
return | ||
} | ||
} | ||
Write-Host "-----------------------------------------" | ||
If ([string]::IsNullOrEmpty($result) ) { | ||
Write-Host "No changes found" | ||
return | ||
} else { | ||
Write-Host "Changes found to create comment with!" | ||
} | ||
|
||
$prompt = @" | ||
Your mission is to create clean and comprehensive overview of the changes as per the GitMoji specification conventional commit convention and explain: | ||
- **WHAT** were the changes | ||
- **WHY** the changes were done | ||
I'll send you an output of the `git diff` command, and you are to convert it into a list of commits .For each commit Use GitMoji convention to preface each commit. Here are some help to choose the right emoji (emoji, description): | ||
- 🐛, Fix a bug | ||
- ✨, Introduce new features | ||
- 📝, Add or update documentation | ||
- 🚀, Deploy stuff | ||
- ✅, Add, update, or pass tests | ||
- ♻️, Refactor code | ||
- ⬆️, Upgrade dependencies | ||
- 🔧, Add or update configuration files | ||
- 🌐, Internationalization and localization | ||
- 💡, Add or update comments in source code | ||
- 🎨, Improve structure/format of the code | ||
- ⚡️, Improve performance | ||
- 🔥, Remove code or files | ||
- 🚑️, Critical hotfix | ||
- 💄, Add or update the UI and style files | ||
- 🎉, Begin a project | ||
- 🔒️, Fix security issues | ||
- 🔐, Add or update secrets | ||
- 🔖, Release / Version tags | ||
- 🚨, Fix compiler / linter warnings | ||
- 🚧, Work in progress | ||
- 💚, Fix CI Build | ||
- ⬇️, Downgrade dependencies | ||
- 📌, Pin dependencies to specific versions | ||
- 👷, Add or update CI build system | ||
- 📈, Add or update analytics or track code | ||
- ➕, Add a dependency | ||
- ➖, Remove a dependency | ||
- 🔨, Add or update development scripts | ||
- ✏️, Fix typos | ||
- 💩, Write bad code that needs to be improved | ||
- ⏪️, Revert changes | ||
- 🔀, Merge branches | ||
- 📦️, Add or update compiled files or packages | ||
- 👽️, Update code due to external API changes | ||
- 🚚, Move or rename resources (e.g., files, paths, routes) | ||
- 📄, Add or update license | ||
- 💥, Introduce breaking changes | ||
- 🍱, Add or update assets | ||
- ♿️, Improve accessibility | ||
- 🍻, Write code drunkenly | ||
- 💬, Add or update text and literals | ||
- 🗃️, Perform database related changes | ||
- 🔊, Add or update logs | ||
- 🔇, Remove logs | ||
- 👥, Add or update contributor(s) | ||
- 🚸, Improve user experience / usability | ||
- 🏗️, Make architectural changes | ||
- 📱, Work on responsive design | ||
- 🤡, Mock things | ||
- 🥚, Add or update an easter egg | ||
- 🙈, Add or update a .gitignore file | ||
- 📸, Add or update snapshots | ||
- ⚗️, Perform experiments | ||
- 🔍️, Improve SEO | ||
- 🏷️, Add or update types | ||
- 🌱, Add or update seed files | ||
- 🚩, Add, update, or remove feature flags | ||
- 🥅, Catch errors | ||
- 💫, Add or update animations and transitions | ||
- 🗑️, Deprecate code that needs to be cleaned up | ||
- 🛂, Work on code related to authorization, roles and permissions | ||
- 🩹, Simple fix for a non-critical issue | ||
- 🧐, Data exploration/inspection | ||
- ⚰️, Remove dead code | ||
- 🧪, Add a failing test | ||
- 👔, Add or update business logic | ||
- 🩺, Add or update healthcheck | ||
- 🧱, Infrastructure related changes | ||
- 🧑💻, Improve developer experience | ||
- 💸, Add sponsorships or money related infrastructure | ||
- 🧵, Add or update code related to multithreading or concurrency | ||
- 🦺, Add or update code related to validation | ||
Conventional commit keywords: fix, feat, build, chore, ci, docs, style, refactor, perf, test. | ||
- On the same line include a short description of **WHY** the changes are done after the commit message. | ||
- Don't start it with "This commit", just describe the changes. | ||
- Don't add any descriptions to the commit, only commit message. | ||
At the beginning of the list of changes, add an overview of the changes in the following format: | ||
- Look at the overall archtecture and changes and describe the value of this release in a single paragraph. | ||
- Do not add a title. | ||
Aditional information: | ||
- Use the present tense. | ||
- Lines must not be longer than 74 characters. | ||
- Use en-gb for the commit message. | ||
"@ | ||
|
||
$prompt2 = @" | ||
You are an expert in software development and business communication. You are given the JSON output of a git log or git diff command, capturing changes made between the last software release and the current one. Your task is to create a clear, detailed, and business-friendly summary of these changes. | ||
Instructions: | ||
1. Group by Intent: Organize the changes into categories based on the intent of the changes. Possible categories include (title, emoji, description): | ||
- New Features, ✨, Describe any new functionalities added. | ||
- Enhancements, 💡,Outline improvements to existing features. | ||
- Bug Fixes, 🐛,Summarize issues resolved. | ||
- Performance Improvements, ⚡️,Note optimizations made for better performance. | ||
- Refactoring, ♻️,Explain changes aimed at code structure improvement without altering functionality. | ||
- Security Updates, 🔒️,Highlight security-related changes. | ||
- Documentation Updates, 📝, Mention improvements or additions to documentation. | ||
- Dependency Updates, 📌,Specify updates to libraries, packages, or tools. | ||
- Other, 🧱,Capture any other changes that don’t fit the above categories. | ||
2. Link to Pull Requests: Where applicable, reference the relevant Pull Requests (PRs) by number or link, providing context on the reason for the changes. | ||
3. Provide Context: For each category, offer a brief explanation of why these changes were necessary or beneficial from a business perspective. | ||
4. Output Structure: | ||
- Overview: Begin with a high-level summary of the release. | ||
- Detailed Changes: Break down the changes by the categories above, including a description and the impact of each change. | ||
- Conclusion: Finish with a conclusion that provides a brief outlook on the impact these changes are expected to have on the overall project or business goals. | ||
5. Tone: The summary should be written in a professional tone that is accessible to non-technical stakeholders but detailed enough for technical team members. | ||
6. Aditional information: | ||
- Use the present tense. | ||
- Use en-gb for the commit message. | ||
- Use https://github.com/nkdAgility/azure-devops-migration-tools as the github repository | ||
"@ | ||
|
||
# Set the API endpoint and API key | ||
$apiUrl = "https://api.openai.com/v1/chat/completions" | ||
|
||
# Convert $resultItems to a single string | ||
#$resultItemsString = $resultItems -join "`n" | ||
|
||
# Prepare the full prompt with the git diff results appended | ||
$fullPrompt = $prompt2 + "`n`nUse the folowing json:`n`n" + $result | ||
|
||
Write-Host "-----------------------------------------" | ||
Write-Host "Prompt:" | ||
Write-Host $fullPrompt | ||
|
||
Write-Host "-----------------------------------------" | ||
# Create the body for the API request | ||
Write-Host "Create the body for the API request..." | ||
$body = @{ | ||
"model" = "gpt-4-turbo" | ||
"messages" = @( | ||
@{ | ||
"role" = "system" | ||
"content" = "You are an expert assistant that generates high-quality, structured content based on Git diffs using the GitMoji specification. You follow UK English conventions and keep lines under 74 characters." | ||
}, | ||
@{ | ||
"role" = "user" | ||
"content" = $fullPrompt | ||
} | ||
) | ||
"temperature" = 0 | ||
"max_tokens" = 2048 | ||
} | ConvertTo-Json | ||
Write-Host "Body:" | ||
Write-Host $body | ||
|
||
|
||
Write-Host "-----------------------------------------" | ||
Write-Host "Sending request to the ChatGPT API..." | ||
# Send the request to the ChatGPT API | ||
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers @{ | ||
"Content-Type" = "application/json" | ||
"Authorization" = "Bearer $OPEN_AI_KEY" | ||
} -Body $body | ||
|
||
Write-Host "-----------------------------------------" | ||
Write-Host "Extracting Output.." | ||
# Extract and display the response content | ||
$result = $response.choices[0].message.content | ||
Write-Host "-----------------------------------------" | ||
Write-Host "result:" | ||
Write-Host $result | ||
Write-Host "-----------------------------------------" | ||
Write-Host "-----------------------------------------" | ||
Write-Host "Returning.." | ||
return $result | ||
} |