Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Action to setup release candidate branch #4204

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/setupReleaseBranch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Set up a new Release Candidate

on:
workflow_dispatch:
inputs:
commitId:
description: "Commit Id"
default: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we default this to the current HEAD of main

required: true
type: string
versionNumber:
description: "Version number/name"
default: ""
required: true
type: string

jobs:
setupReleaseCandidateBranch:
name: Setup a release candidate branch
runs-on: ubuntu-latest
env:
releaseBranchPattern: "release/candidate/*"
steps:
- name: Sync code
uses: actions/checkout@v4
with:
ref: ${{ inputs.commitId }}

- name: Check if remote branch exists
run: |
if git ls-remote --exit-code --heads origin $releaseBranchPattern; then
echo "EXISTS=true" >> $GITHUB_ENV
echo "Release candidate branch already exists"
exit 1
else
echo "EXISTS=false" >> $GITHUB_ENV
echo "Release candidate branch does not exist"
fi

- name: Set up release branch
env:
releaseBranch: "release/candidate/${{inputs.versionNumber}}"
if: ${{ env.EXISTS == 'false' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this if the previous step will exit with failure

Copy link
Contributor

@rli rli Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions

        if: ${{ success() }}

also works, to avoid polluting the env vars

run: |
git checkout -b $releaseBranch
git push --set-upstream origin $releaseBranch