|
| 1 | +name: Build the last successful automatic rebase of tb-dev branch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + dry_run: |
| 7 | + description: > |
| 8 | + Set this input to do a dry run without building the packages to test |
| 9 | + the rebase. |
| 10 | + required: false |
| 11 | + type: boolean |
| 12 | + default: false |
| 13 | + schedule: |
| 14 | + - cron: '0 0 * * 6' |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: automatic-rebase |
| 18 | + |
| 19 | +jobs: |
| 20 | + prep-rebase: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + steps: |
| 25 | + - name: Checkout qubes-grub2 |
| 26 | + uses: actions/checkout@v6 |
| 27 | + with: |
| 28 | + repository: QubesOS/qubes-grub2 |
| 29 | + path: qubes-grub2 |
| 30 | + - name: Checkout downstream grub repository |
| 31 | + uses: actions/checkout@v6 |
| 32 | + with: |
| 33 | + repository: TrenchBoot/grub |
| 34 | + token: ${{ secrets.TRENCHBOOT_REBASE_TOKEN }} |
| 35 | + path: grub |
| 36 | + - name: Read upstream version from qubes-grub2 |
| 37 | + id: version |
| 38 | + working-directory: qubes-grub2 |
| 39 | + run: echo "version=$(cat version)" >> "$GITHUB_OUTPUT" |
| 40 | + - name: Add upstream remote and fetch version tag |
| 41 | + working-directory: grub |
| 42 | + env: |
| 43 | + UPSTREAM_TAG: grub-${{ steps.version.outputs.version }} |
| 44 | + run: | |
| 45 | + git remote add upstream https://gitlab.freedesktop.org/gnu-grub/grub.git |
| 46 | + git fetch upstream "refs/tags/${UPSTREAM_TAG}:refs/tags/${UPSTREAM_TAG}" |
| 47 | + - name: Apply qubes-grub2 patches on top of upstream tag |
| 48 | + working-directory: grub |
| 49 | + env: |
| 50 | + UPSTREAM_TAG: grub-${{ steps.version.outputs.version }} |
| 51 | + run: | |
| 52 | + git checkout -b qubes-grub2-with-patches-rebase-prep "$UPSTREAM_TAG" |
| 53 | + SPEC="../qubes-grub2/grub2.spec.in" |
| 54 | + mapfile -t PATCHES < <(grep -E '^Patch[0-9]+:' "$SPEC" | awk '{print $2}') |
| 55 | + for patch_file in "${PATCHES[@]}"; do |
| 56 | + git apply "../qubes-grub2/${patch_file}" |
| 57 | + escaped=$(printf '%s' "$patch_file" | sed 's/\./\\./g') |
| 58 | + sed -i "/^Patch[0-9]*:[[:space:]]*${escaped}[[:space:]]*$/d" "$SPEC" |
| 59 | + rm -f "../qubes-grub2/${patch_file}" |
| 60 | + done |
| 61 | + - name: Copy QubesOS RPM files to downstream repository |
| 62 | + run: | |
| 63 | + cp -r qubes-grub2/* grub/ |
| 64 | + cd grub |
| 65 | + git add -A |
| 66 | + GIT_AUTHOR_NAME="github-actions[bot]" \ |
| 67 | + GIT_AUTHOR_EMAIL="github-actions[bot]@users.noreply.github.com" \ |
| 68 | + GIT_AUTHOR_DATE="2024-01-01T00:00:00" \ |
| 69 | + GIT_COMMITTER_NAME="github-actions[bot]" \ |
| 70 | + GIT_COMMITTER_EMAIL="github-actions[bot]@users.noreply.github.com" \ |
| 71 | + GIT_COMMITTER_DATE="2024-01-01T00:00:00" \ |
| 72 | + git commit --no-gpg-sign -m "QubesOS patches, QubesOS RPM files and Qubes builder metadata" |
| 73 | + - name: Push qubes-grub2-with-patches branch to downstream |
| 74 | + working-directory: grub |
| 75 | + run: git push origin qubes-grub2-with-patches-rebase-prep |
| 76 | + try-rebase: |
| 77 | + needs: prep-rebase |
| 78 | + uses: TrenchBoot/.github/.github/workflows/rebase.yml@v1 |
| 79 | + secrets: |
| 80 | + first-remote-token: ${{secrets.TRENCHBOOT_REBASE_TOKEN}} |
| 81 | + permissions: |
| 82 | + # For creation/deletion/pushing to branches and creating PRs |
| 83 | + contents: write |
| 84 | + with: |
| 85 | + downstream-repo: 'https://github.com/TrenchBoot/grub.git' |
| 86 | + downstream-branch: 'tb-dev' |
| 87 | + upstream-repo: 'https://github.com/TrenchBoot/grub.git' |
| 88 | + upstream-branch: 'qubes-grub2-with-patches-rebase-prep' |
| 89 | + commit-user-name: 'github-actions[bot]' |
| 90 | + commit-user-email: 'github-actions[bot]@users.noreply.github.com' |
| 91 | + cicd-trigger-resume: '7. Rerun the workflow https://github.com/TrenchBoot/grub/actions/runs/${{ github.run_id }} to resume automated rebase.' |
| 92 | + cleanup-after-rebase-attempt: |
| 93 | + needs: try-rebase |
| 94 | + if: always() |
| 95 | + runs-on: ubuntu-latest |
| 96 | + permissions: |
| 97 | + contents: read |
| 98 | + steps: |
| 99 | + - name: Checkout downstream grub repository |
| 100 | + uses: actions/checkout@v6 |
| 101 | + with: |
| 102 | + repository: TrenchBoot/grub |
| 103 | + token: ${{ secrets.TRENCHBOOT_REBASE_TOKEN }} |
| 104 | + path: grub |
| 105 | + - name: Delete qubes-grub2-with-patches branch from downstream |
| 106 | + working-directory: grub |
| 107 | + env: |
| 108 | + TOKEN: ${{ secrets.TRENCHBOOT_REBASE_TOKEN }} |
| 109 | + run: | |
| 110 | + git push "https://${TOKEN}@github.com/TrenchBoot/grub.git" \ |
| 111 | + --delete qubes-grub2-with-patches-rebase-prep |
| 112 | + get-version: |
| 113 | + runs-on: ubuntu-latest |
| 114 | + needs: try-rebase |
| 115 | + if: ${{ needs.try-rebase.outputs.rebase-exit-code == '0' && inputs.dry_run != 'true' }} |
| 116 | + outputs: |
| 117 | + version: ${{ steps.read-version.outputs.version }} |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@v6 |
| 120 | + with: |
| 121 | + ref: 'tb-dev-rebased' |
| 122 | + - name: Read version of the QubesOS Component from version file |
| 123 | + id: read-version |
| 124 | + # The tb-dev-rebased should already have the version file either created |
| 125 | + # in the prep-rebase or try-rebase jobs (it will be probably created by |
| 126 | + # the prep-rebase as this file is a part of QubesOS repository) on which |
| 127 | + # it depennds: |
| 128 | + run: echo "version=$(cat version)" >> "$GITHUB_OUTPUT" |
| 129 | + qubes-dom0-package: |
| 130 | + needs: get-version |
| 131 | + uses: TrenchBoot/.github/.github/workflows/qubes-dom0-packagev2.yml@v1 |
| 132 | + with: |
| 133 | + qubes-component: 'grub2' |
| 134 | + qubes-component-branch: 'tb-dev-rebased' |
| 135 | + qubes-pkg-src-dir: '.' |
| 136 | + qubes-pkg-version: ${{ needs.get-version.outputs.version }} |
| 137 | + trigger-woodpecker-cicd: |
| 138 | + needs: qubes-dom0-package |
| 139 | + uses: TrenchBoot/.github/.github/workflows/trigger-woodpecker-pipeline.yml@v1 |
| 140 | + secrets: |
| 141 | + woodpecker-token: ${{ secrets.WOODPECKER_TOKEN }} |
| 142 | + with: |
| 143 | + api-url: 'https://ci.3mdeb.com' |
| 144 | + owner: 'zarhus' |
| 145 | + repo: 'trenchboot-release-cicd-pipeline' |
| 146 | + ref: 'master' |
| 147 | + inputs: >- |
| 148 | + --input GITHUB_REPO=grub |
| 149 | + --input GITHUB_SHA=${{ github.sha }} |
| 150 | + --input GITHUB_RUN_ID=${{ github.run_id }} |
| 151 | + --input QUBES_COMPONENT=grub2 |
| 152 | + --input WORKFLOW=sign-and-publish-test-rpms |
0 commit comments