Skip to content

Commit ee4ff34

Browse files
ci: Update release workflow
1 parent 1df68f7 commit ee4ff34

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed

Diff for: .github/workflows/release.yml

+32-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1+
# on:
2+
# workflow_dispatch:
3+
# inputs:
4+
# version:
5+
# type: string
6+
# description: 'Version'
7+
# required: true
18
on:
29
push:
310
branches:
4-
- master
11+
- feat/changelog
512

613
permissions:
714
contents: write
815
pull-requests: write
916

10-
name: release-please
17+
name: release
1118

1219
jobs:
13-
release-please:
20+
tag:
1421
runs-on: ubuntu-latest
1522
steps:
16-
- uses: googleapis/release-please-action@v4
23+
- uses: actions/checkout@v4
1724
with:
18-
token: ${{ secrets.GH_TOKEN }}
19-
release-type: simple
25+
fetch-depth: 0
26+
- name: Install Neovim
27+
uses: rhysd/action-setup-vim@v1
28+
id: neovim
29+
with:
30+
neovim: true
31+
version: v0.10.3
32+
- name: Update changelog
33+
run: |
34+
nvim -l scripts/generate_changelog.lua 0.4.2
35+
# nvim -l scripts/generate_changelog.lua ${{ github.event.inputs.version }}
36+
- name: Print generated changelog
37+
run: |
38+
cat docs/changelog.org
39+
- name: Get release info
40+
id: release_info
41+
run: |
42+
echo "RELEASE_INFO=<<EOF\n$(nvim -l scripts/generate_changelog.lua 0.4.2 print)\EOF" >> $GITHUB_OUTPUT
43+
- name: Print release info
44+
run:
45+
echo "${{ steps.release_info.outputs.RELEASE_INFO }}"

Diff for: scripts/generate_changelog.lua

+23-9
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ local function populate_section(content, name, list)
1111
)
1212
content[#content + 1] = ''
1313
end
14-
local function generate_changelog()
14+
15+
local function get_changes()
1516
local latest_tag = vim.fn.system('git describe --tags `git rev-list --tags --max-count=1`'):gsub('\n', '')
16-
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..master --pretty=format:'%s'")
17+
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..feat/changelog --pretty=format:'%s'")
1718
local fixes = {}
1819
local features = {}
1920
local breaking_changes = {}
@@ -32,26 +33,39 @@ local function generate_changelog()
3233
end
3334
end
3435
end
36+
local content = {}
37+
38+
populate_section(content, 'Breaking changes', breaking_changes)
39+
populate_section(content, 'Features', features)
40+
populate_section(content, 'Bug fixes', fixes)
41+
42+
return content
43+
end
44+
45+
local function generate_changelog()
3546
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) }
3947

4048
local new_content = {
4149
'** ' .. new_tag,
4250
'- Date: [[' .. os.date('%Y-%m-%d') .. ']]',
4351
('- [[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),
52+
('- [[https://github.com/nvim-orgmode/orgmode/releases/tag/%s][Link to release]]'):format(new_tag),
4553
'',
4654
}
47-
populate_section(new_content, 'Breaking changes', breaking_changes)
48-
populate_section(new_content, 'Features', features)
49-
populate_section(new_content, 'Bug fixes', fixes)
55+
vim.list_extend(new_content, get_changes())
56+
57+
local changelog = vim.fn.readfile('./docs/changelog.org')
58+
local start = { unpack(changelog, 1, 2) }
59+
local remaining = { unpack(changelog, 3) }
5060

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

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

67+
if arg[2] and arg[2] == 'print' then
68+
return print(table.concat(get_changes(), '\n'))
69+
end
70+
5771
generate_changelog()

0 commit comments

Comments
 (0)