Skip to content

Commit 5a24ab8

Browse files
ci: Update release workflow
1 parent 1df68f7 commit 5a24ab8

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,49 @@
11
on:
2-
push:
3-
branches:
4-
- master
2+
workflow_dispatch:
3+
inputs:
4+
version:
5+
type: string
6+
description: 'Version'
7+
required: true
58

69
permissions:
710
contents: write
811
pull-requests: write
912

10-
name: release-please
13+
name: release
1114

1215
jobs:
13-
release-please:
16+
release:
1417
runs-on: ubuntu-latest
1518
steps:
16-
- uses: googleapis/release-please-action@v4
19+
- uses: actions/checkout@v4
1720
with:
21+
fetch-depth: 0
1822
token: ${{ secrets.GH_TOKEN }}
19-
release-type: simple
23+
- name: Install Neovim
24+
uses: rhysd/action-setup-vim@v1
25+
id: neovim
26+
with:
27+
neovim: true
28+
version: v0.10.3
29+
- name: Update changelog
30+
run: |
31+
nvim -l scripts/generate_changelog.lua ${{ github.event.inputs.version }}
32+
- name: Print generated changelog
33+
run: |
34+
cat docs/changelog.org
35+
- name: Get release info
36+
id: release_info
37+
run: |
38+
changes=$(nvim -l scripts/generate_changelog.lua ${{ github.event.inputs.version }} print)
39+
{
40+
echo 'output<<EOF'
41+
echo "$changes"
42+
echo 'EOF'
43+
} >> $GITHUB_OUTPUT
44+
# - name: Tag new version
45+
# run: |
46+
# git tag -a ${{ github.event.inputs.version }} -m "Release ${{ github.evente.inputs.version }}"
47+
- name: Print release info
48+
run:
49+
echo "${{ steps.release_info.outputs.output }}"

scripts/generate_changelog.lua

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ local function populate_section(content, name, list)
1111
)
1212
content[#content + 1] = ''
1313
end
14-
local function generate_changelog()
15-
local latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
14+
15+
local function get_changes(latest_tag)
16+
if not latest_tag then
17+
latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
18+
end
1619
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..master --pretty=format:'%s'")
1720
local fixes = {}
1821
local features = {}
@@ -32,26 +35,40 @@ local function generate_changelog()
3235
end
3336
end
3437
end
38+
local content = {}
39+
40+
populate_section(content, 'Breaking changes', breaking_changes)
41+
populate_section(content, 'Features', features)
42+
populate_section(content, 'Bug fixes', fixes)
43+
44+
return content
45+
end
46+
47+
local function generate_changelog()
48+
local latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
3549
local new_tag = arg[1]
36-
local changelog = vim.fn.readfile('./docs/changelog.org')
37-
local start = { unpack(changelog, 1, 2) }
38-
local remaining = { unpack(changelog, 3) }
3950

4051
local new_content = {
4152
'** ' .. new_tag,
4253
'- Date: [[' .. os.date('%Y-%m-%d') .. ']]',
4354
('- [[https://github.com/nvim-orgmode/orgmode/compare/%s...%s][Compare]]'):format(latest_tag, new_tag),
44-
('- [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]'):format(latest_tag),
55+
('- [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]'):format(new_tag),
4556
'',
4657
}
47-
populate_section(new_content, 'Breaking changes', breaking_changes)
48-
populate_section(new_content, 'Features', features)
49-
populate_section(new_content, 'Bug fixes', fixes)
58+
vim.list_extend(new_content, get_changes(latest_tag))
59+
60+
local changelog = vim.fn.readfile('./docs/changelog.org')
61+
local start = { unpack(changelog, 1, 2) }
62+
local remaining = { unpack(changelog, 3) }
5063

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

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

70+
if arg[2] and arg[2] == 'print' then
71+
return io.write(table.concat(get_changes(), '\n'))
72+
end
73+
5774
generate_changelog()

0 commit comments

Comments
 (0)