From e2927e4ed21974ca1c261060a28c0d8d5554cbe8 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Mon, 20 Oct 2025 17:00:31 +0300 Subject: [PATCH] Misc OBS changes * Patch the spec file with the explicit version Thus we no longer need OBS to successfully run set_version service. * Sign spec/service files Probably irrelevant, but may be better than nothing? * Attest the OBS repo content, state that in OBS repo commit msg --- .github/workflows/deb-orchestrator.yml | 4 + .github/workflows/obs.yml | 101 +++++++++++++++++++++---- 2 files changed, 92 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deb-orchestrator.yml b/.github/workflows/deb-orchestrator.yml index 1adf214d..8909be8a 100644 --- a/.github/workflows/deb-orchestrator.yml +++ b/.github/workflows/deb-orchestrator.yml @@ -28,6 +28,10 @@ jobs: GPG_SIGNING_SUBKEY_FINGERPRINT: ${{ secrets.GPG_SIGNING_SUBKEY_FINGERPRINT }} obs: needs: source-only + permissions: + id-token: write + contents: read + attestations: write if: github.event_name != 'pull_request' && (github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref_name == 'master')) uses: ./.github/workflows/obs.yml with: diff --git a/.github/workflows/obs.yml b/.github/workflows/obs.yml index c8c34633..aaed489a 100644 --- a/.github/workflows/obs.yml +++ b/.github/workflows/obs.yml @@ -127,11 +127,13 @@ jobs: eatmydata apt full-upgrade eatmydata apt install \ ca-certificates \ + coreutils \ curl \ git \ git-lfs \ gnupg \ openssh-client \ + patch \ tar \ xz-utils \ zip \ @@ -149,7 +151,6 @@ jobs: gpg --import <> ~/.gnupg/gpg-agent.conf + echo "enable-ssh-support" >> ~/.gnupg/gpg-agent.conf + gpgconf --kill gpg-agent + gpgconf --launch gpg-agent + gpg-connect-agent 'keyattr ${{ secrets.GPG_AUTH_SUBKEY_KEYGRIP }} Use-for-ssh: true' /bye - name: Ensure that the download directory does not exist timeout-minutes: 1 run: | @@ -230,7 +236,7 @@ jobs: echo 'ok.' && \ echo '::endgroup::' \ " - - name: Update OBS Repo + - name: Checkout the OBS Repo timeout-minutes: 1 shell: sudo podman exec --interactive --tty container eatmydata sh "{0}" run: | @@ -243,38 +249,77 @@ jobs: mkdir -p ~/.ssh echo "" >> ~/.ssh/config echo "StrictHostKeyChecking=accept-new" >> ~/.ssh/config - echo "" >> ~/.gnupg/gpg-agent.conf - echo "enable-ssh-support" >> ~/.gnupg/gpg-agent.conf - gpgconf --kill gpg-agent - gpgconf --launch gpg-agent export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) - gpg-connect-agent 'keyattr ${{ secrets.GPG_AUTH_SUBKEY_KEYGRIP }} Use-for-ssh: true' /bye OBS_REPO_URL="${{ secrets[format('OBS_{0}_REPO_URL', env.SUITE)] }}" OBS_REPO_DIR="${{ github.workspace }}/bcachefs-obs" git clone "$OBS_REPO_URL" "$OBS_REPO_DIR" + git config --global --add safe.directory "$OBS_REPO_DIR" + - name: Update OBS Repo state + timeout-minutes: 1 + shell: sudo podman exec --interactive --tty container eatmydata sh "{0}" + run: | + set -xe + OBS_REPO_DIR="${{ github.workspace }}/bcachefs-obs" cd "$OBS_REPO_DIR" - git config --global --add safe.directory . git rm -rf --ignore-unmatch -- . tee .gitattributes > /dev/null < /dev/null < /dev/null < /dev/null < - EOT for FILENAME in *; do - CHECKSUM="$(sha256sum "$FILENAME" | awk '{print $1}')" + CHECKSUM="$(sha256sum -b "$FILENAME" | awk '{print $1}')" tee -a "${{ github.workspace }}/_service" > /dev/null < $FILENAME @@ -287,7 +332,37 @@ jobs: EOT mv "${{ github.workspace }}/_service" "$OBS_REPO_DIR" - VER="$(basename --suffix=.tar.xz $(ls *.tar.xz))" + for f in "$OBS_REPO_DIR/_service"; do + echo "::group::Signing $f" + gpg --verbose --detach-sign $f + echo '::endgroup::' + done git add . - git commit --message="Update to $VER" + - name: Prepare OBS Repo state for attestation + timeout-minutes: 1 + shell: sudo podman exec --interactive --tty container eatmydata sh "{0}" + run: | + set -xe + OBS_REPO_DIR="${{ github.workspace }}/bcachefs-obs" + cd "$OBS_REPO_DIR" + (git ls-files --cached | xargs sha256sum -b) > "${{ github.workspace }}/bcachefs-obs.sha256sums" + - name: Attest the current OBS Repo state + timeout-minutes: 1 + # if: github.event_name != 'pull_request' + id: attestation + uses: actions/attest-build-provenance@v3 + with: + subject-checksums: '${{ github.workspace }}/bcachefs-obs.sha256sums' + - name: Push updated OBS Repo + timeout-minutes: 1 + shell: sudo podman exec --interactive --tty container eatmydata sh "{0}" + run: | + set -xe + export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) + OBS_REPO_DIR="${{ github.workspace }}/bcachefs-obs" + tee -a "$OBS_REPO_DIR/.git/COMMIT_EDITMSG" > /dev/null <