|
10 | 10 | required: false |
11 | 11 | type: choice |
12 | 12 | options: |
| 13 | + - '' |
13 | 14 | - linux-nvidia-6.6 |
14 | 15 | - linux-nvidia-6.12 |
15 | 16 | - linux-nvidia-6.18 |
16 | 17 |
|
17 | 18 | jobs: |
18 | | - update-rebase-branch: |
| 19 | + prepare: |
19 | 20 | runs-on: ubuntu-latest |
20 | | - strategy: |
21 | | - fail-fast: false |
22 | | - matrix: |
23 | | - branch: |
24 | | - - linux-nvidia-6.6 |
25 | | - - linux-nvidia-6.12 |
26 | | - - linux-nvidia-6.18 |
| 21 | + outputs: |
| 22 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
27 | 23 | steps: |
28 | | - - name: Check if branch should be processed |
29 | | - id: check |
| 24 | + - name: Build matrix |
| 25 | + id: set-matrix |
30 | 26 | run: | |
31 | | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
32 | | - # Skip only if a specific branch was selected AND it's not this one |
33 | | - # Empty means process all branches |
34 | | - if [ -n "${{ inputs.branch }}" ] && [ "${{ inputs.branch }}" != "${{ matrix.branch }}" ]; then |
35 | | - echo "skip=true" >> $GITHUB_OUTPUT |
36 | | - else |
37 | | - echo "skip=false" >> $GITHUB_OUTPUT |
38 | | - fi |
| 27 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.branch }}" ]; then |
| 28 | + branches='${{ inputs.branch }}' |
39 | 29 | else |
40 | | - echo "skip=false" >> $GITHUB_OUTPUT |
| 30 | + branches='linux-nvidia-6.6 linux-nvidia-6.12 linux-nvidia-6.18' |
41 | 31 | fi |
42 | 32 |
|
43 | | - - name: Checkout target branch |
44 | | - if: steps.check.outputs.skip != 'true' |
45 | | - uses: actions/checkout@v4 |
46 | | - with: |
47 | | - ref: ${{ matrix.branch }} |
48 | | - fetch-depth: 0 |
49 | | - |
50 | | - - name: Add upstream remote (if not exists) |
51 | | - if: steps.check.outputs.skip != 'true' |
52 | | - run: | |
53 | | - if ! git remote | grep -q upstream; then |
54 | | - git remote add upstream https://github.com/gregkh/linux.git |
55 | | - fi |
| 33 | + matrix='{"include":[' |
| 34 | + first=true |
| 35 | + for branch in $branches; do |
| 36 | + version=$(echo "$branch" | sed 's/^linux-nvidia-//') |
56 | 37 |
|
57 | | - - name: Fetch upstream tags |
58 | | - if: steps.check.outputs.skip != 'true' |
59 | | - run: git fetch upstream --tags --force |
| 38 | + # Query tags remotely without fetching |
| 39 | + tag=$(git ls-remote --tags https://github.com/gregkh/linux.git "v${version}.*" | \ |
| 40 | + grep -v '\^{}' | \ |
| 41 | + sed 's|.*/||' | \ |
| 42 | + sort -V | \ |
| 43 | + tail -1) |
60 | 44 |
|
61 | | - - name: Find latest stable tag for branch |
62 | | - if: steps.check.outputs.skip != 'true' |
63 | | - id: latest_tag |
| 45 | + if [ "$first" = true ]; then |
| 46 | + first=false |
| 47 | + else |
| 48 | + matrix+=',' |
| 49 | + fi |
| 50 | + matrix+="{\"branch\":\"$branch\",\"tag\":\"$tag\"}" |
| 51 | + done |
| 52 | + matrix+=']}' |
| 53 | +
|
| 54 | + echo "matrix=$matrix" >> $GITHUB_OUTPUT |
| 55 | +
|
| 56 | + update-rebase-branch: |
| 57 | + needs: prepare |
| 58 | + runs-on: ubuntu-latest |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} |
| 62 | + outputs: |
| 63 | + branch-6-6: ${{ steps.mark-success.outputs.branch-6-6 }} |
| 64 | + branch-6-12: ${{ steps.mark-success.outputs.branch-6-12 }} |
| 65 | + branch-6-18: ${{ steps.mark-success.outputs.branch-6-18 }} |
| 66 | + steps: |
| 67 | + - name: Checkout target branch |
64 | 68 | run: | |
65 | | - version=$(echo "${{ matrix.branch }}" | sed 's/^linux-nvidia-//') |
66 | | - tag=$(git describe --abbrev=0 --tags upstream/linux-${version}.y) |
67 | | - echo "tag=$tag" >> $GITHUB_OUTPUT |
| 69 | + git init -q |
| 70 | + git remote add origin https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git |
| 71 | + git fetch origin ${{ matrix.branch }} |
| 72 | + git checkout -b ${{ matrix.branch }} origin/${{ matrix.branch }} |
68 | 73 |
|
69 | | - - name: Fetch patch branch |
70 | | - if: steps.check.outputs.skip != 'true' |
71 | | - run: git fetch origin ${{ matrix.branch }} |
| 74 | + - name: Fetch upstream tag |
| 75 | + run: | |
| 76 | + git remote add upstream https://github.com/gregkh/linux.git |
| 77 | + git fetch upstream tag ${{ matrix.tag }} --no-tags |
72 | 78 |
|
73 | | - - name: Find merge base between patch branch and updated LTS |
74 | | - if: steps.check.outputs.skip != 'true' |
| 79 | + - name: Find merge base |
75 | 80 | id: merge_base |
76 | 81 | run: | |
77 | | - base=$(git merge-base origin/${{ matrix.branch }} ${{ steps.latest_tag.outputs.tag }}) |
| 82 | + base=$(git merge-base HEAD ${{ matrix.tag }}) |
78 | 83 | echo "base=$base" >> $GITHUB_OUTPUT |
79 | 84 |
|
80 | | - - name: Create new branch for rebased patches |
81 | | - if: steps.check.outputs.skip != 'true' |
| 85 | + - name: Create rebased branch |
82 | 86 | run: | |
83 | | - git checkout -b ${{ matrix.branch }}-${{ steps.latest_tag.outputs.tag }} origin/${{ matrix.branch }} |
| 87 | + git checkout -b ${{ matrix.branch }}-${{ matrix.tag }} |
84 | 88 |
|
85 | 89 | - name: Set git user identity |
86 | | - if: steps.check.outputs.skip != 'true' |
87 | 90 | run: | |
88 | | - git config --local user.name "github-actions[bot]" |
89 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 91 | + git config user.name "github-actions[bot]" |
| 92 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
90 | 93 |
|
91 | | - - name: Rebase patch branch onto updated LTS |
92 | | - if: steps.check.outputs.skip != 'true' |
| 94 | + - name: Rebase onto upstream tag |
93 | 95 | run: | |
94 | | - git rebase --onto ${{ steps.latest_tag.outputs.tag }} ${{ steps.merge_base.outputs.base }} |
| 96 | + git rebase --onto ${{ matrix.tag }} ${{ steps.merge_base.outputs.base }} |
95 | 97 |
|
96 | | - - name: Push rebased patch branch |
97 | | - if: steps.check.outputs.skip != 'true' |
| 98 | + - name: Push rebased branch |
98 | 99 | run: | |
99 | | - git push --force origin HEAD:${{ matrix.branch }}-${{ steps.latest_tag.outputs.tag }} |
| 100 | + git push --force origin HEAD:${{ matrix.branch }}-${{ matrix.tag }} |
100 | 101 |
|
101 | | - - name: Trigger kernel build for rebased branch |
102 | | - if: steps.check.outputs.skip != 'true' |
103 | | - env: |
104 | | - GH_TOKEN: ${{ github.token }} |
| 102 | + - name: Mark rebase successful |
| 103 | + id: mark-success |
105 | 104 | run: | |
106 | | - gh workflow run kernel-build.yml \ |
107 | | - --ref github-actions \ |
108 | | - -f branch=${{ matrix.branch }}-${{ steps.latest_tag.outputs.tag }} |
| 105 | + key=$(echo "${{ matrix.branch }}" | sed 's/linux-nvidia-/branch-/' | tr '.' '-') |
| 106 | + echo "${key}=${{ matrix.branch }}-${{ matrix.tag }}" >> $GITHUB_OUTPUT |
| 107 | +
|
| 108 | + build-6-6: |
| 109 | + needs: [prepare, update-rebase-branch] |
| 110 | + if: ${{ !cancelled() && needs.update-rebase-branch.outputs.branch-6-6 != '' }} |
| 111 | + uses: ./.github/workflows/kernel-build.yml |
| 112 | + with: |
| 113 | + branch: ${{ needs.update-rebase-branch.outputs.branch-6-6 }} |
| 114 | + |
| 115 | + build-6-12: |
| 116 | + needs: [prepare, update-rebase-branch] |
| 117 | + if: ${{ !cancelled() && needs.update-rebase-branch.outputs.branch-6-12 != '' }} |
| 118 | + uses: ./.github/workflows/kernel-build.yml |
| 119 | + with: |
| 120 | + branch: ${{ needs.update-rebase-branch.outputs.branch-6-12 }} |
| 121 | + |
| 122 | + build-6-18: |
| 123 | + needs: [prepare, update-rebase-branch] |
| 124 | + if: ${{ !cancelled() && needs.update-rebase-branch.outputs.branch-6-18 != '' }} |
| 125 | + uses: ./.github/workflows/kernel-build.yml |
| 126 | + with: |
| 127 | + branch: ${{ needs.update-rebase-branch.outputs.branch-6-18 }} |
0 commit comments