Skip to content

Commit 3251c5c

Browse files
committed
Add workflow to automatically create a release
1 parent 21a479f commit 3251c5c

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
name: Update the v1 branch when a release is published
1+
name: Create a Release
22
on:
3-
release:
4-
types: [published]
3+
workflow_dispatch:
54
permissions:
6-
contents: read
5+
contents: write # for creating release
76

87
jobs:
98
release:
109
runs-on: ubuntu-latest
11-
permissions:
12-
contents: write # for git push
1310
steps:
1411
- uses: actions/checkout@v4
1512
with:
1613
fetch-depth: 0
17-
- run: git push origin HEAD:v1
14+
- uses: ./
15+
with:
16+
ruby-version: '3.3'
17+
- run: ruby release.rb
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Update the v1 branch when a release is published
2+
on:
3+
release:
4+
types: [published]
5+
permissions:
6+
contents: write # for git push
7+
8+
jobs:
9+
update_branch:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- run: git push origin HEAD:v1

release.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'json'
2+
3+
def run(command_line)
4+
puts "$ #{command_line}"
5+
output = `#{command_line}`
6+
puts output
7+
raise $?.inspect unless $?.success?
8+
output
9+
end
10+
11+
latest_release_tag = run 'gh release view --json tagName'
12+
latest_release_tag = JSON.load(latest_release_tag).fetch('tagName')
13+
14+
raise latest_release_tag unless latest_release_tag =~ /\Av(\d+).(\d+).(\d+)\z/
15+
tag = "v#{$1}.#{Integer($2)+1}.0"
16+
17+
run "gh release create --generate-notes --latest #{tag}"

0 commit comments

Comments
 (0)