diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c5de1e67..464d939a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/update-v1-branch.yml b/.github/workflows/update-v1-branch.yml new file mode 100644 index 000000000..f497b7209 --- /dev/null +++ b/.github/workflows/update-v1-branch.yml @@ -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 diff --git a/release.rb b/release.rb new file mode 100644 index 000000000..4bf822ba9 --- /dev/null +++ b/release.rb @@ -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}"