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