From 515334a202b882d4ec4022a6028cee23cc43bb70 Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Tue, 16 May 2023 20:47:49 +0800 Subject: [PATCH 1/4] ci: setup git in a separate step --- .github/workflows/test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f6a5fbaa5530..7f0bd67e5c4d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,15 +23,19 @@ jobs: - name: Checkout uses: actions/checkout@v3.5.2 - - name: Apply patches + - name: Setup Git env: - KORG_STABLE_URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git CI_COMMIT_AUTHOR: Continuous Integration run: | - git branch spec-branch git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" git config --global user.email "username@users.noreply.github.com" + - name: Apply patches + env: + KORG_STABLE_URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git + run: | + git branch spec-branch + spec="$(git show "spec-branch:linux.spec")" kver=$(echo "${spec}" | awk '/^Version:/ { print $2; }') echo "kver=${kver}" >> "$GITHUB_ENV" From 8abbc8bb218c2b17bf031a5e8777ce6918b1cf45 Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Wed, 17 May 2023 00:05:26 +0800 Subject: [PATCH 2/4] ci: move an env var to job scope --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f0bd67e5c4d..9b3744ac05b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,8 @@ on: jobs: apply-patches: runs-on: ubuntu-latest + env: + KORG_STABLE_URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git steps: - name: Checkout uses: actions/checkout@v3.5.2 @@ -31,8 +33,6 @@ jobs: git config --global user.email "username@users.noreply.github.com" - name: Apply patches - env: - KORG_STABLE_URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git run: | git branch spec-branch From 0d42f27fa603cfb1a0e54bc6e1a0d7f8d3c093b4 Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Wed, 17 May 2023 00:09:25 +0800 Subject: [PATCH 3/4] ci: create spec containing branch in separate step --- .github/workflows/test.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b3744ac05b3..a158b67cc220 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,11 +32,15 @@ jobs: git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" git config --global user.email "username@users.noreply.github.com" - - name: Apply patches + - name: Create spec containing branch run: | - git branch spec-branch + spec_branch=spec-branch + git branch "${spec_branch}" + echo "spec_branch=${spec_branch}" >> "$GITHUB_ENV" - spec="$(git show "spec-branch:linux.spec")" + - name: Apply patches + run: | + spec="$(git show "${spec_branch}:linux.spec")" kver=$(echo "${spec}" | awk '/^Version:/ { print $2; }') echo "kver=${kver}" >> "$GITHUB_ENV" release=$(echo "${spec}" | awk '/^Release:/ { print $2; }') @@ -49,7 +53,7 @@ jobs: for patch_id in $(echo "${spec}" | awk '/^%patch/ { print $1; }'); do patch_id="Patch${patch_id#%patch}"; patch="$(echo "${spec}" | awk "/^${patch_id}/ { print \$2; }")"; - git show "spec-branch:${patch}" | \ + git show "${spec_branch}:${patch}" | \ git am --3way --signoff --committer-date-is-author-date; done git log --graph --oneline "v${kver}..HEAD" From 69a24d300ebcdea7a69b66d10f4d5485848744bc Mon Sep 17 00:00:00 2001 From: You-Sheng Yang Date: Tue, 16 May 2023 21:02:15 +0800 Subject: [PATCH 4/4] ci: merge upstream automatically --- .github/workflows/test.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a158b67cc220..ee69cfbec9e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,9 +21,12 @@ jobs: runs-on: ubuntu-latest env: KORG_STABLE_URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git + CLEARLINUX_URL: https://github.com/clearlinux-pkgs/linux.git steps: - name: Checkout uses: actions/checkout@v3.5.2 + with: + fetch-depth: ${{ (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/main' && 1000 || 1 }} - name: Setup Git env: @@ -32,9 +35,21 @@ jobs: git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" git config --global user.email "username@users.noreply.github.com" - - name: Create spec containing branch + - name: Merge Upstream run: | spec_branch=spec-branch + if [ "yes" == ${{ (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/main' && 'yes' || 'no' }} ]; then + git remote add clearlinux "${CLEARLINUX_URL}"; + git fetch clearlinux refs/heads/main:refs/remotes/clearlinux/main; + ver_current="$(git show "HEAD:linux.spec" | awk '/^Version:/ { kver=$2; } /^Release:/ { release=$2; } END { print kver "-" release; }')"; + ver_remote="$(git show "clearlinux/main:linux.spec" | awk '/^Version:/ { kver=$2; } /^Release:/ { release=$2; } END { print kver "-" release; }')"; + if [ "${ver_current}" != "${ver_remote}" ] && [ "$(git describe --tags clearlinux/main)" == "${ver_remote}" ]; then + if ! git merge -m "Merge remote-tracking branch 'clearlinux/main'" clearlinux/main; then + echo "Skip merging clearlinux/main"; + git merge --abort; + fi; + fi; + fi git branch "${spec_branch}" echo "spec_branch=${spec_branch}" >> "$GITHUB_ENV"