Skip to content

Commit

Permalink
Update release notes history after every release
Browse files Browse the repository at this point in the history
After every release a PR is created with release notes prepended in file ReleaseNotes.md in root dir
  • Loading branch information
MichalBrylka committed Aug 9, 2024
1 parent 72eaf5f commit e0a38cc
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ on:
deploy_nuget_locally:
type: boolean
description: 🚀 deploy package to GH private
default: false
default: false
push:
branches:
- 'main'
paths-ignore:
- '*.md'

pull_request:
branches:
- '*'
paths-ignore:
- '*.md'
release:
types:
- published

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: "CodeQL"
on:
workflow_dispatch:
pull_request:
branches: [ main ]
branches: [ main ]
paths-ignore:
- '*.md'
schedule:
- cron: '40 16 * * 0'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/license-scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
pull_request:
branches:
- '*'
paths-ignore:
- '*.md'

run-name: "License Scanning"

Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/update-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: 'Update release notes history'
on:
release:
types:
- published

defaults:
run:
shell: pwsh

jobs:
update_notes:
name: 📜 update notes
runs-on: ubuntu-latest
steps:
- name: 🤘 checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🗎 create release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ github.event.release.name }}
RELEASE_BODY: ${{ github.event.release.body }}
run: |
$NL = "`r`n"
$name = $env:RELEASE_NAME
$body = $env:RELEASE_BODY
$releaseNumber = "${{ github.event.release.tag_name }}"
$publishedAt = [DateTime]::Parse("${{ github.event.release.published_at }}").ToUniversalTime().ToString('yyyy-MM-dd HH:mm:ss') + " GMT"
$url = "${{ github.event.release.html_url }}"
$authorLogin = "${{ github.event.release.author.login }}"
$authorUrl = "${{ github.event.release.author.html_url }}"
$releaseNotes = "# Release $releaseNumber"
if($name){
$releaseNotes += " - $name"
}
$releaseNotes += $NL
$releaseNotes += "Published [$publishedAt]($url) by [$authorLogin]($authorUrl)" + $NL
if($body){
$releaseNotes += "$NL$body"
}
$releaseNotes += $NL
$releaseNotes | Set-Content -Encoding UTF8 "ReleaseNotesFromLastRelease.md"
- name: ⬆️ upload release notes
uses: actions/upload-artifact@v4
with:
name: ReleaseNotes
if-no-files-found: error
retention-days: 7
path: ReleaseNotesFromLastRelease.md
- name: 🚀 create pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git --version
git config user.name "GitHub Actions Bot"
git config user.email "<>"
$releaseNumber = "${{ github.event.release.tag_name }}"
$branchName = "build/update-release-notes-$releaseNumber-$(Get-Date -Format "yyyyMMdd_HHmmss")"
$lastReleaseNotes = Get-Content -Encoding UTF8 "ReleaseNotesFromLastRelease.md" -Raw
$lastReleaseNotes + (Get-Content .\ReleaseNotes.md -Raw -Encoding UTF8) | Set-Content .\ReleaseNotes.md -Encoding UTF8
Remove-Item ReleaseNotesFromLastRelease.md
$title = "Update release notes after release $releaseNumber"
git checkout -b $branchName
git add .
git commit -m $title
git push --set-upstream origin $branchName
gh pr create -B main -H $branchName --title $title --body 'Created by Github action'
1 change: 1 addition & 0 deletions Nemesis.TextParsers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
.github\workflows\license-scanning.yml = .github\workflows\license-scanning.yml
.github\workflows\update-release-notes.yml = .github\workflows\update-release-notes.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nemesis.TextParsers.DependencyInjection", "Nemesis.TextParsers.DependencyInjection\Nemesis.TextParsers.DependencyInjection.csproj", "{55D14092-BD6A-4076-A5D7-B9E5C57C8D67}"
Expand Down

0 comments on commit e0a38cc

Please sign in to comment.