Skip to content

Sync release candidate with main #56

Sync release candidate with main

Sync release candidate with main #56

Workflow file for this run

# This workflow will sync changes in the release candidate branch to main during a
# feature freeze. The action is run daily and will only create a pull request when
# there exists a release candidate branch corresponding to the current package version
# as declared in catalyst/frontend/_version.py.
name: Sync release candidate with main
# Controls when the workflow will run
on:
# Scheduled trigger every weekday at 2:47am UTC
schedule:
- cron: '47 2 * * 1-5'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job to sync the main branch with changes from the rc
sync:
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out the Catalyst repository
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Import Numpy/Pybind11 because it is imported in setup.py
- name: Install Numpy and Pybind11
run: |
python -m pip install --upgrade pip
pip install numpy pybind11
# Check for the existence of an rc branch for the current Catalyst version
- name: Check for rc branch
run: |
VERSION=$(python setup.py --version)
IFS=. read MAJ MIN PAT <<< "${VERSION%.dev[0-9]*}"
RC_BRANCH="v${MAJ}.$((MIN-1)).${PAT}-rc"
if git ls-remote --exit-code origin "refs/heads/$RC_BRANCH"; then
echo "branch_exists=true" >> $GITHUB_ENV
echo "rc_branch=$RC_BRANCH" >> $GITHUB_ENV
else
echo "branch_exists=false" >> $GITHUB_ENV
fi
echo "new_changes=false" >> $GITHUB_ENV
# Create a new branch at from the current rc to be used in the PR
- name: Create temp branch
if: ${{ env.branch_exists == 'true' }}
run: |
git fetch
git checkout "${{ env.rc_branch }}"
BRANCH="rc_$(date +'%Y-%m-%d-%H-%M-%S')"
echo "tmp_branch=$BRANCH" >> $GITHUB_ENV
git checkout -b "$BRANCH"
# Exclude some files known to be divergent during the release process from the PR
git checkout origin/main -- frontend/catalyst/_version.py
git checkout origin/main -- doc/dev/release_notes.rst
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git commit -m "exclude files from pr"
# check for new changes on the rc branch only, based on the diff between main and rc
if ! git diff origin/main HEAD --quiet -- $(git diff --name-only origin/main...HEAD); then
echo "new_changes=true" >> $GITHUB_ENV
git push --set-upstream origin "$BRANCH"
fi
# Create PR to main
- name: Create pull request
if: ${{ env.new_changes == 'true' }}
uses: repo-sync/pull-request@v2
with:
source_branch: "${{ env.tmp_branch }}"
destination_branch: "main"
github_token: "${{ secrets.GITHUB_TOKEN }}"
pr_title: "Daily rc sync to main"
pr_body: "Automatic sync from the release candidate to main during a feature freeze."
pr_allow_empty: false
pr_draft: false
pr_reviewer: "dime10,joeycarter"