Skip to content

Commit

Permalink
Add workflow to automatically create a release
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jun 27, 2024
1 parent 21a479f commit 3251c5c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Update the v1 branch when a release is published
name: Create a Release
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
contents: write # for creating release

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # for git push
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git push origin HEAD:v1
- uses: ./
with:
ruby-version: '3.3'
- run: ruby release.rb
15 changes: 15 additions & 0 deletions .github/workflows/update-v1-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Update the v1 branch when a release is published
on:
release:
types: [published]
permissions:
contents: write # for git push

jobs:
update_branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git push origin HEAD:v1
17 changes: 17 additions & 0 deletions release.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'json'

def run(command_line)
puts "$ #{command_line}"
output = `#{command_line}`
puts output
raise $?.inspect unless $?.success?
output
end

latest_release_tag = run 'gh release view --json tagName'
latest_release_tag = JSON.load(latest_release_tag).fetch('tagName')

raise latest_release_tag unless latest_release_tag =~ /\Av(\d+).(\d+).(\d+)\z/
tag = "v#{$1}.#{Integer($2)+1}.0"

run "gh release create --generate-notes --latest #{tag}"

0 comments on commit 3251c5c

Please sign in to comment.