Skip to content

Commit

Permalink
Add workflow to sync from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
chadrako committed Jan 8, 2024
1 parent 57853ac commit 73cdc1c
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 19 deletions.
19 changes: 19 additions & 0 deletions .github/actions/fetch-repo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Fetch upstream repository'
description: 'Fetch the upstream openjdk repository and update the corresponding branches'

inputs:
upstream:
description: 'Upstream repository https git url'
required: true
local-branch:
description: 'Local branch tracking the remote upstream'
required: true
outputs:
status:
description: 'Status of the upstream fetch and merge'
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/refresh.sh ${{ inputs.upstream }} ${{ inputs.local-branch }}
shell: bash
id: fetch-and-update-repo
11 changes: 11 additions & 0 deletions .github/actions/fetch-repo/refresh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -x

UPSTREAM=$1
LOCAL_BRANCH=$2

REMOTE_NAME=upstream-${LOCAL_BRANCH}
git remote add ${REMOTE_NAME} ${UPSTREAM}
git fetch origin ${LOCAL_BRANCH}:${LOCAL_BRANCH} || exit 1
git fetch ${REMOTE_NAME} master:${LOCAL_BRANCH} || exit 1
git push origin ${LOCAL_BRANCH}
19 changes: 19 additions & 0 deletions .github/actions/merge-repo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Merge Upstream branch'
description: 'Merge Upstream branch to Develop branch.'

inputs:
upstream:
description: 'Upstream branch in repository'
required: true
merge-branch:
description: 'Merge branch in local repository'
required: true
outputs:
status:
description: 'Status of the upstream fetch and merge'
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/merge.sh ${{ inputs.upstream }} ${{ inputs.merge-branch }}
shell: bash
id: merge-upstream-to-develop
13 changes: 13 additions & 0 deletions .github/actions/merge-repo/merge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -x

UPSTREAM_BRANCH=$1
MERGE_BRANCH=$2

git config user.email "[email protected]"
git config user.name "corretto-github-robot"

git checkout ${MERGE_BRANCH}
git merge -m "Merge ${UPSTREAM_BRANCH}" ${UPSTREAM_BRANCH} || exit 1

git push origin ${MERGE_BRANCH}
19 changes: 19 additions & 0 deletions .github/actions/update-version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Update Corretto version'
description: 'Update the version based on upstream configuration'

inputs:
upstream:
description: 'upstream remote suffix'
required: true
version-branch:
description: 'Branch to update version of'
required: true
outputs:
status:
description: 'Status of the update of the version'
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/update-version.sh ${{ inputs.upstream }} ${{ inputs.version-branch }}
shell: bash
id: update-version
29 changes: 29 additions & 0 deletions .github/actions/update-version/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -x

UPSTREAM_REMOTE=upstream-$1
VERSION_BRANCH=$2

git config user.email "[email protected]"
git config user.name "corretto-github-robot"

git checkout ${VERSION_BRANCH}

# Load the current OpenJDK version
source make/conf/version-numbers.conf

BUILD_NUMBER=$(git ls-remote --tags ${UPSTREAM_REMOTE} |grep jdk-${DEFAULT_VERSION_FEATURE}.${DEFAULT_VERSION_INTERIM}.${DEFAULT_VERSION_UPDATE} | grep -vE "(-ga|{})$" | cut -d+ -f 2 |sort -n |tail -1)

# Load the current Corretto version
CURRENT_VERSION=$(cat version.txt)

if [[ ${CURRENT_VERSION} == ${DEFAULT_VERSION_FEATURE}.${DEFAULT_VERSION_INTERIM}.${DEFAULT_VERSION_UPDATE}.${BUILD_NUMBER:=0}.* ]]; then
echo "Corretto version is current."
else
echo "Updating Corretto version"
NEW_VERSION="${DEFAULT_VERSION_FEATURE}.${DEFAULT_VERSION_INTERIM}.${DEFAULT_VERSION_UPDATE}.${BUILD_NUMBER}.1"
echo "${NEW_VERSION}" > version.txt
git commit -m "Update Corretto version to match upstream: ${NEW_VERSION}" version.txt
git push origin ${VERSION_BRANCH}
fi
42 changes: 23 additions & 19 deletions .github/workflows/refresh-jdk.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: "Refresh jdk from Upstream"
name: "Refresh jdk21 from Upstream"
on:
schedule:
- cron: '0 8 * * *'
- cron: '0 7 * * *'
workflow_dispatch:
env:
UPSTREAM_REMOTE: https://github.com/openjdk/jdk21u
LOCAL_BRANCH: develop

jobs:
refresh-jdk:
refresh-jdk21:
runs-on: ubuntu-latest
name: "Update Corretto-21"
if: github.repository_owner == 'corretto'
Expand All @@ -16,17 +14,23 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ env.LOCAL_BRANCH }}
- name: "Configure the user"
run: |
git config user.email "[email protected]"
git config user.name "corretto-github-robot"
- name: "Merge openjdk/jdk:master to the corretto-21:develop"
run: |
git fetch $UPSTREAM_REMOTE master || exit 1
git merge -m "Merge upstream-jdk" FETCH_HEAD
- name: "Fetch Corretto-21 upstream"
uses: ./.github/actions/fetch-repo
with:
upstream: 'https://github.com/openjdk/jdk21u.git'
local-branch: 'upstream'
- name: "Merge Corretto-21"
uses: ./.github/actions/merge-repo
with:
upstream: 'upstream'
merge-branch: 'develop'
- name: "Update Corretto version"
shell: bash
run: bash ./.github/scripts/update-version.sh $UPSTREAM_REMOTE
- name: "Push to the corretto-21"
run: git push origin $LOCAL_BRANCH
uses: ./.github/actions/update-version
with:
upstream: 'upstream'
version-branch: 'develop'
- name: "Merge Corretto-21 develop to nightly"
uses: ./.github/actions/merge-repo
with:
upstream: 'develop'
merge-branch: 'nightly'
31 changes: 31 additions & 0 deletions .github/workflows/refresh-jdk21-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Refresh jdk21u-dev from Upstream"
on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch:

jobs:
refresh-jdk21-dev:
runs-on: ubuntu-latest
name: "Update Corretto-21 nightly"
if: github.repository_owner == 'corretto'
steps:
- name: "Checkout code"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "Fetch Corretto-21"
uses: ./.github/actions/fetch-repo
with:
upstream: 'https://github.com/openjdk/jdk21u-dev.git'
local-branch: 'upstream-jdk21u-dev'
- name: "Merge Corretto-21"
uses: ./.github/actions/merge-repo
with:
upstream: 'upstream-jdk21u-dev'
merge-branch: 'nightly'
- name: "Update Corretto version"
uses: ./.github/actions/update-version
with:
upstream: 'upstream-jdk21u-dev'
version-branch: 'nightly'

0 comments on commit 73cdc1c

Please sign in to comment.