Skip to content

Commit

Permalink
Add workflow for creating release branches
Browse files Browse the repository at this point in the history
This change adds a GitHub Actions workflow for creating release branches
with steps to generate the THIRD_PARTY_LICENSES file and updates the
getting started guide with the new release version.

Signed-off-by: Austin Vazquez <[email protected]>
  • Loading branch information
austinvazquez committed May 23, 2024
1 parent 0615443 commit cbbe038
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .github/actions/update-getting-started/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Update getting started version"
description: "Reusable action to update the getting started version"
inputs:
version:
required: true
description: "Recommended SOCI version"

runs:
using: composite
steps:
- name: "Update getting started version"
shell: bash
run: |
version=${{ inputs.version }}
version=${version/v/} # strip prefix v if not already stripped
sed -i -E "s/version=\"([0-9]+\.){2}[0-9]+\"/version=\"${version}\"/" docs/getting-started.md
git diff
84 changes: 84 additions & 0 deletions .github/workflows/create-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Create release branch

on:
workflow_dispatch:
inputs:
major_minor_version:
description: |
Major.Minor release version
(e.g. 0.6)
required: true
base_commit:
description: |
Base commit SHA
(e.g. be8940b39667bc3975cf7ea8a71177e4bfb5f6e0)
required: true
pull_request:
branches: ['main']
paths:
- '.github/workflows/create-release-branch.yml'

permissions:
contents: write
pull-requests: write

jobs:
create-branch:
runs-on: ubuntu-20.04
env:
MAJOR_MINOR_VERSION: ''
BASE_COMMIT: ''
steps:
- uses: actions/checkout@v4

- name: Mock workflow inputs on pull request
if: github.event_name == 'pull_request'
run: |
echo "MAJOR_MINOR_VERSION=pr.${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "BASE_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Set environment variables for workflow
if: github.event_name == 'workflow_dispatch'
run: |
echo "MAJOR_MINOR_VERSION=${{ github.event.inputs.major_minor_version }}" >> $GITHUB_ENV
echo "BASE_COMMIT=${{ github.event.inputs.base_commit }}" >> $GITHUB_ENV
- name: Create release branch
run: git checkout -b release/${{ env.MAJOR_MINOR_VERSION }} ${{ env.BASE_COMMIT }}

- name: Push new release branch
if: github.event_name == 'workflow_dispatch'
run: git push origin release/${{ env.MAJOR_MINOR_VERSION }}

- uses: ./.github/actions/update-getting-started
with:
version: ${{ env.MAJOR_MINOR_VERSION }}.0

- uses: actions/setup-go@v5

- name: Install go-licenses
run: go install github.com/google/[email protected]

- name: Generate third party licenses file
run: scripts/build-third-party-licenses.sh

- name: Create PR
if: github.event_name == 'workflow_dispatch'
uses: peter-evans/create-pull-request@v6
with:
title: 'Prepare release ${{ env.MAJOR_MINOR_VERSION }}'
commit-message: |
Prepare release ${{ env.MAJOR_MINOR_VERSION }}
This change adds the THIRD_PARTY_LICENSES file and updates the getting started guide for release/${{ env.MAJOR_MINOR_VERSION }}.
body: |
This change adds the THIRD_PARTY_LICENSES file and updates the getting started guide for release/${{ env.MAJOR_MINOR_VERSION }}.
Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request)
labels: easy-to-review, automated-pr
token: ${{ secrets.GITHUB_TOKEN }}
author: "GitHub <[email protected]>"
signoff: true
branch: 'create-pull-request/prepare-release-${{ env.MAJOR_MINOR_VERSION }}'
base: 'release/${{ env.MAJOR_MINOR_VERSION }}'
delete-branch: true
17 changes: 7 additions & 10 deletions .github/workflows/update-getting-started-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@ jobs:
update-version:
runs-on: ubuntu-20.04
env:
RELEASE_TAG: ''
RELEASE_VERSION: ''
steps:
- uses: actions/checkout@v4

- name: Mock release tag on pull request
if: github.event_name == 'pull_request'
run: echo "RELEASE_TAG=v0.0.0-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
run: echo "RELEASE_VERSION=v0.0.0-${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: Set published release tag
if: github.event_name == 'release'
run: echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- name: Update getting started version
run: |
release_tag=${{ env.RELEASE_TAG }}
release_version=${release_tag/v/}
sed -i -E "s/version=\"([0-9]+\.){2}[0-9]+\"/version=\"${release_version}\"/" docs/getting-started.md
git diff
run: echo "RELEASE_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- uses: ./.github/actions/update-getting-started
with:
version: ${{ env.RELEASE_VERSION }}

- name: Create PR
if: github.event_name == 'release'
Expand Down

0 comments on commit cbbe038

Please sign in to comment.