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 5a24ab8
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 16 deletions.
44 changes: 37 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
on:
push:
branches:
- master
workflow_dispatch:
inputs:
version:
type: string
description: 'Version'
required: true

permissions:
contents: write
pull-requests: write

name: release-please
name: release

jobs:
release-please:
release:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
release-type: simple
- 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 ${{ 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 ${{ github.event.inputs.version }} print)
{
echo 'output<<EOF'
echo "$changes"
echo 'EOF'
} >> $GITHUB_OUTPUT
# - name: Tag new version
# run: |
# git tag -a ${{ github.event.inputs.version }} -m "Release ${{ github.evente.inputs.version }}"
- 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,8 +11,11 @@ local function populate_section(content, name, list)
)
content[#content + 1] = ''
end
local function generate_changelog()
local latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')

local function get_changes(latest_tag)
if not latest_tag then
latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
end
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..master --pretty=format:'%s'")
local fixes = {}
local features = {}
Expand All @@ -32,26 +35,40 @@ 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 latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
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(latest_tag))

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
return io.write(table.concat(get_changes(), '\n'))
end

generate_changelog()

0 comments on commit 5a24ab8

Please sign in to comment.