Skip to content

Commit

Permalink
scaffold workflows to handle automated rebasing of changes to make re…
Browse files Browse the repository at this point in the history
…lease automation boring (#1074 #1075)
  • Loading branch information
shiftkey committed Jun 2, 2024
1 parent 0aa23bf commit 2303fa5
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 'Create draft release from upstream'

on:
workflow_dispatch:
inputs:
release:
description: 'Upstream release'
required: true
type: string
publish:
description: 'Whether to publish the release to GitHub on success'
type: boolean
required: false
default: false

jobs:
publish-draft-release:
runs-on: ubuntu-latest
name: Publish draft release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.CREATE_RELEASE_AUTOMATION_TOKEN }}
- name: Configure git
run: |
git config --global user.name "shiftbot"
git config --global user.email "github@brendanforster.com"
git config --local core.autocrlf "input"
git remote add upstream https://github.com/desktop/desktop.git
shell: bash
- name: Create baseline branch on fork
id: create-baseline-branch
env:
RELEASE_TAG: ${{ inputs.release }}
BASE_BRANCH: 'linux-${{ inputs.release }}'
run: |
git fetch upstream 'refs/tags/*:refs/tags/*'
git fetch origin --unshallow
git checkout -b $BASE_BRANCH $RELEASE_TAG
git push origin $BASE_BRANCH
git config -l --show-origin
shell: bash
- name: Rebase Linux customizations on top of upstream release branch
id: rebase-linux-branch
env:
HEAD_BRANCH: 'apply-changes-${{ inputs.release }}'
BASE_BRANCH: 'linux-${{ inputs.release }}'
UPSTREAM_BRANCH: 'development'
run: |
git fetch origin linux
git fetch origin $UPSTREAM_BRANCH
git checkout -b $HEAD_BRANCH linux
git push origin $HEAD_BRANCH
git submodule update
echo "One last git config output..."
git config -l --show-origin
echo "Commit identifiers before performing rebase..."
echo "BASE_BRANCH: $(git rev-parse $BASE_BRANCH)"
echo "development: $(git rev-parse origin/$UPSTREAM_BRANCH)"
echo "HEAD_BRANCH: $(git rev-parse $HEAD_BRANCH)"
echo "About to run 'git log --oneline --decorate=full --graph $HEAD_BRANCH...origin/$UPSTREAM_BRANCH'..."
git log --oneline --decorate=full --graph $HEAD_BRANCH...origin/$UPSTREAM_BRANCH
echo "About to run 'git rebase --verbose origin/$UPSTREAM_BRANCH $HEAD_BRANCH --onto $BASE_BRANCH'..."
git rebase --verbose origin/$UPSTREAM_BRANCH $HEAD_BRANCH --onto $BASE_BRANCH
git push origin $HEAD_BRANCH
shell: bash
continue-on-error: true
- name: Review current status
id: status
run: |
git status
shell: bash
43 changes: 43 additions & 0 deletions .github/workflows/sync-with-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Sync main branch with upstream'

on: workflow_dispatch

jobs:
sync-with-upstream:
runs-on: ubuntu-latest
name: Sync main branch with upstream
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.CREATE_RELEASE_AUTOMATION_TOKEN }}
- name: Configure git
run: |
git config --global user.name "shiftbot"
git config --global user.email "github@brendanforster.com"
git remote add upstream https://github.com/desktop/desktop.git
shell: bash
- name: Push development changes from upstream to fork
id: sync-development-branch
run: |
git fetch upstream development
git fetch origin --unshallow
git fetch origin development
git checkout -b development upstream/development
git push origin development
shell: bash
- name: Rebase Linux customizations on top of development branch
id: rebase-linux-branch
run: |
git fetch origin linux
git checkout linux
git log linux...development --oneline
git rebase --verbose development linux
shell: bash
continue-on-error: true
- name: Review current status
id: status
run: |
git status
shell: bash
# TODO: force push this when we're confident that the rebase has succeeded?

0 comments on commit 2303fa5

Please sign in to comment.