Skip to content

Commit 0009922

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

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

Diff for: .github/workflows/release.yml

+37-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
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+
changes=$(nvim -l scripts/generate_changelog.lua 0.4.2 print)
43+
{
44+
echo 'output<<EOF'
45+
echo "$changes"
46+
echo 'EOF'
47+
} >> $GITHUB_OUTPUT
48+
- name: Print release info
49+
run:
50+
echo "${{ steps.release_info.outputs.output }}"

Diff for: scripts/generate_changelog.lua

+27-10
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ 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', '')
16-
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..master --pretty=format:'%s'")
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
19+
local commits = vim.fn.systemlist('git log ' .. latest_tag .. "..feat/changelog --pretty=format:'%s'")
1720
local fixes = {}
1821
local features = {}
1922
local breaking_changes = {}
@@ -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)