Skip to content

Commit

Permalink
ci: Update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kristijanhusak committed Feb 1, 2025
1 parent 1df68f7 commit 5c91fc2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
43 changes: 37 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
# on:
# workflow_dispatch:
# inputs:
# version:
# type: string
# description: 'Version'
# required: true
on:
push:
branches:
- master
- feat/changelog

permissions:
contents: write
pull-requests: write

name: release-please
name: release

jobs:
release-please:
tag:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
release-type: simple
fetch-depth: 0
- name: Install Neovim
uses: rhysd/action-setup-vim@v1
id: neovim
with:
neovim: true
version: v0.10.3
- name: Update changelog
run: |
nvim -l scripts/generate_changelog.lua 0.4.2
# nvim -l scripts/generate_changelog.lua ${{ github.event.inputs.version }}
- name: Print generated changelog
run: |
cat docs/changelog.org
- name: Get release info
id: release_info
run: |
changes=$(nvim -l scripts/generate_changelog.lua 0.4.2 print)
{
echo 'output<<EOF'
echo "$changes"
echo 'EOF'
} >> $GITHUB_OUTPUT
- name: Print release info
run:
echo "${{ steps.release_info.outputs.output }}"
35 changes: 26 additions & 9 deletions scripts/generate_changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ local function populate_section(content, name, list)
)
content[#content + 1] = ''
end
local function generate_changelog()

local function get_changes()
local latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..master --pretty=format:'%s'")
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..feat/changelog --pretty=format:'%s'")
local fixes = {}
local features = {}
local breaking_changes = {}
Expand All @@ -32,26 +33,42 @@ local function generate_changelog()
end
end
end
local content = {}

populate_section(content, 'Breaking changes', breaking_changes)
populate_section(content, 'Features', features)
populate_section(content, 'Bug fixes', fixes)

return content
end

local function generate_changelog()
local new_tag = arg[1]
local changelog = vim.fn.readfile('./docs/changelog.org')
local start = { unpack(changelog, 1, 2) }
local remaining = { unpack(changelog, 3) }

local new_content = {
'** ' .. new_tag,
'- Date: [[' .. os.date('%Y-%m-%d') .. ']]',
('- [[https://github.com/nvim-orgmode/orgmode/compare/%s...%s][Compare]]'):format(latest_tag, new_tag),
('- [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]'):format(latest_tag),
('- [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]'):format(new_tag),
'',
}
populate_section(new_content, 'Breaking changes', breaking_changes)
populate_section(new_content, 'Features', features)
populate_section(new_content, 'Bug fixes', fixes)
vim.list_extend(new_content, get_changes())

local changelog = vim.fn.readfile('./docs/changelog.org')
local start = { unpack(changelog, 1, 2) }
local remaining = { unpack(changelog, 3) }

local new_changelog = vim.list_extend(start, new_content)
new_changelog = vim.list_extend(new_changelog, remaining)

vim.fn.writefile(new_changelog, './docs/changelog.org')
end

if arg[2] and arg[2] == 'print' then
local changes = {'<<EOF'}
vim.list_extend(changes, get_changes())
table.insert(changes, 'EOF')
return print(table.concat(changes, '\n'))
end

generate_changelog()

0 comments on commit 5c91fc2

Please sign in to comment.