Skip to content

Instantly share code, notes, and snippets.

@sheldonhull
Last active November 17, 2023 13:22
Show Gist options
  • Save sheldonhull/9257a3081ca2c5cd3a54cf4b08e1d7f6 to your computer and use it in GitHub Desktop.
Save sheldonhull/9257a3081ca2c5cd3a54cf4b08e1d7f6 to your computer and use it in GitHub Desktop.
example changie-config for multiple projects in continue.dev
changesDir: .changes
unreleasedDir: unreleased
headerPath: header.tpl.md
changelogPath: CHANGELOG.md
versionExt: md
versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
kindFormat: ''
changeFormat: '- `{{.Kind}}`: {{.Body}}'
body:
block: true
projects:
- label: project # i use this for anything on project workings worth noting
key: project
changelog: CHANGELOG.md
- label: server
key: server
changelog: server/CHANGELOG.md
- label: extensions/intellij
key: extensions/intellij
changelog: extensions/intellij/CHANGELOG.md
- label: extensions/vscode
key: extensions/vscode
changelog: extensions/vscode/CHANGELOG.md
- label: docs
key: docs
changelog: docs/CHANGELOG.md # for releasing documents independently
projectsVersionSeparator: /
kinds:
- label: 🤖 CI & Build
auto: patch
- label: 🎉 New Product Feature
auto: minor
- label: ⬇️ Deprecated
auto: minor
- label: 🧪 Tests
auto: patch
- label: 🔨 Refactor
auto: patch
- label: 🐛 Bug Fix
auto: patch
- label: 🔥 Breaking Change
auto: minor
- label: 🔒 Security
auto: patch
- label: ⬆️ Dependencies
auto: patch
- label: 🔥 Major Version Change (Breaking Changes)
auto: major
newlines:
afterChange: 0
afterChangelogHeader: 1
afterChangelogVersion: 1
afterComponent: 1
afterFooterFile: 1
afterFooter: 1
afterHeaderFile: 1
afterHeaderTemplate: 1
afterKind: 1
afterVersion: 1
beforeChange: 0
beforeChangelogVersion: 0
beforeComponent: 0
beforeFooterFile: 0
beforeFooterTemplate: 0
beforeHeaderFile: 0
beforeHeaderTemplate: 0
beforeKind: 1
beforeVersion: 0
endOfVersion: 0

Using

You'd change from just a simple release to running changie batch auto --project extensions/vscode as the method.

Templating Body

I changed the template to be more compact as I set the monorepo up to run on every path change in .unreleased/*.md, and changie then does:

  • are there unreleased changes detected
  • then runs this... i choose pwsh as it's cross-platform (powershell) and already installed on github + brew install on darwin and a bit cleaner than bash for more complex multi-line scripts.
  • I had chatgpt-4 convert my psuedo-code to actual inline code and comment it in case you want to convert.
  • i gave a version for using gh release create (which is great for sharing on github)
  • another using just tags.
  • maybe it's inspiration for the future! cheers

Template

If you want less compact but normal format for changelog I did this:

versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
kindFormat: '### {{.Kind}}'
changeFormat: '- {{ .Body -}}'
body:
  block: true

Releasing every changie entry you can compact it like in the yaml file included to:

versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
kindFormat: ''
changeFormat: '- `{{.Kind}}`: {{.Body}}'

Whatever works for you!

# Ensure full git checkout
& git checkout $(Build.SourceBranchName)
# Getting the list of projects from the .yaml file
$projects = & yq e '.projects.key' - | ConvertFrom-Json
# List of projects that had changes
$changedFiles = Get-ChildItem -Path .unreleased/*.yaml -Recurse
$ListOfProjectsThatHadChanges = $changedFiles | ForEach-Object { & yq e '.project' $_.FullName } | Select-Object -Unique
# Batching changes for each project
foreach ($project in $projects) {
& changie batch auto --project $project | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "[$project] no project changes detected"
}
}
# Set git config defaults
$lastCommitUser = & git log -1 --pretty=format:'%an <%ae>'
$lastCommitEmail = & git log -1 --pretty=format:'%ce'
& git config user.name $lastCommitUser
& git config user.email $lastCommitEmail
# Add changes to git and commit
& git add .changes/*
if ((& git diff --staged | Measure-Object -Line).Lines -gt 0) {
& git commit -m "ci(release): release for $($ListOfProjectsThatHadChanges -join ', ')"
} else {
Write-Host "no changes detected"
}
# Tagging new versions
foreach ($project in $projects) {
$VersionShouldBePublished = & changie latest --project $project
$VersionExists = & git tag -l | Where-Object { $_ -eq $VersionShouldBePublished }
if (-not $VersionExists) {
& git tag $VersionShouldBePublished
Write-Host "Tagged new version: $VersionShouldBePublished for project: $project"
}
}
# Push changes and tags to the repository
& git push origin $(Build.SourceBranchName)
& git push origin --tags
# Ensure full git checkout
& git checkout $(Build.SourceBranchName)
# Getting the list of projects from the .yaml file
$projects = & yq e '.projects.key' - | ConvertFrom-Json
# List of projects that had changes
$changedFiles = Get-ChildItem -Path .unreleased/*.yaml -Recurse
$ListOfProjectsThatHadChanges = $changedFiles | ForEach-Object { & yq e '.project' $_.FullName } | Select-Object -Unique
# Batching changes for each project
foreach ($project in $projects) {
& changie batch auto --project $project | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "[$project] no project changes detected"
}
}
# Set git config defaults
$lastCommitUser = & git log -1 --pretty=format:'%an <%ae>'
$lastCommitEmail = & git log -1 --pretty=format:'%ce'
& git config user.name $lastCommitUser
& git config user.email $lastCommitEmail
# Add changes to git and commit
& git add .changes/*
if ((& git diff --staged | Measure-Object -Line).Lines -gt 0) {
& git commit -m "ci(release): release for $($ListOfProjectsThatHadChanges -join ', ')"
} else {
Write-Host "no changes detected"
}
# Create releases for new versions
foreach ($project in $projects) {
$VersionShouldBePublished = & changie latest --project $project
$ReleaseExists = & gh release list | Where-Object { $_ -like "*$VersionShouldBePublished*" }
if (-not $ReleaseExists) {
& gh release create $VersionShouldBePublished --title "Release $VersionShouldBePublished" --notes "Auto-generated release for $project"
Write-Host "Created release: $VersionShouldBePublished for project: $project"
}
}
# Push changes to the repository
& git push origin $(Build.SourceBranchName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment