|
| 1 | +name: Publish RPMs to COPR |
| 2 | + |
| 3 | +# Reusable workflow invoked by cargo-dist's release pipeline as a |
| 4 | +# user_publish_job (see dist-workspace.toml `publish-jobs`). |
| 5 | +# |
| 6 | +# Builds an SRPM from packaging/qn-bin.spec — a thin .spec whose %prep |
| 7 | +# downloads the SLSA-attested prebuilt binary cargo-dist publishes for |
| 8 | +# this release and verifies it against the .sha256 sidecar. No Rust |
| 9 | +# toolchain involved on COPR's side; the binary inside the resulting |
| 10 | +# RPM is bit-identical to the one in crates.io, Homebrew, GHCR, .deb, |
| 11 | +# and AUR. |
| 12 | +# |
| 13 | +# `copr-cli build --enable-net=on` is required because the spec's |
| 14 | +# %prep stage fetches the tarball over HTTPS from the GitHub Release. |
| 15 | +on: |
| 16 | + workflow_call: |
| 17 | + inputs: |
| 18 | + plan: |
| 19 | + description: dist-manifest JSON for this announcement |
| 20 | + required: true |
| 21 | + type: string |
| 22 | + |
| 23 | +# Reusable-workflow permissions must not exceed what the caller grants |
| 24 | +# in dist-workspace.toml's github-custom-job-permissions block. We only |
| 25 | +# need to read this repo to access the spec file. |
| 26 | +permissions: |
| 27 | + contents: read |
| 28 | + |
| 29 | +jobs: |
| 30 | + publish: |
| 31 | + runs-on: ubuntu-24.04 |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Extract release tag from plan |
| 36 | + id: meta |
| 37 | + env: |
| 38 | + PLAN: ${{ inputs.plan }} |
| 39 | + run: | |
| 40 | + version=$(echo "$PLAN" | jq -r '.releases[0].app_version') |
| 41 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 42 | +
|
| 43 | + - name: Install rpmbuild + copr-cli |
| 44 | + run: | |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get install -y rpm python3-pip python3-venv |
| 47 | + python3 -m venv "$HOME/copr-venv" |
| 48 | + "$HOME/copr-venv/bin/pip" install --quiet copr-cli rich |
| 49 | + echo "$HOME/copr-venv/bin" >> "$GITHUB_PATH" |
| 50 | +
|
| 51 | + - name: Build SRPM |
| 52 | + env: |
| 53 | + QN_VERSION: ${{ steps.meta.outputs.version }} |
| 54 | + run: | |
| 55 | + # Set up the rpmbuild tree. |
| 56 | + mkdir -p "$HOME/rpmbuild"/{SOURCES,SPECS,SRPMS} |
| 57 | + cp packaging/qn-bin.spec "$HOME/rpmbuild/SPECS/qn-bin.spec" |
| 58 | +
|
| 59 | + # SRPM only has the spec — the sources are fetched by mock at |
| 60 | + # %prep time (Source0/Source1 are URLs, not local files). We |
| 61 | + # pass --nodeps so rpmbuild doesn't try to satisfy |
| 62 | + # BuildRequires on the runner; COPR's mock handles that. |
| 63 | + rpmbuild -bs "$HOME/rpmbuild/SPECS/qn-bin.spec" \ |
| 64 | + --define "_topdir $HOME/rpmbuild" \ |
| 65 | + --define "qn_version $QN_VERSION" \ |
| 66 | + --nodeps |
| 67 | + ls -la "$HOME/rpmbuild/SRPMS/" |
| 68 | +
|
| 69 | + - name: Configure copr-cli |
| 70 | + env: |
| 71 | + # copr-cli doesn't read env vars — it requires a config file at |
| 72 | + # ~/.config/copr in INI format. The four fields are provisioned |
| 73 | + # as separate repo secrets so each can be pasted as a single |
| 74 | + # line and rotated independently. The file is assembled here at |
| 75 | + # runtime. Verbatim values come from |
| 76 | + # https://copr.fedorainfracloud.org/api/. |
| 77 | + COPR_LOGIN: ${{ secrets.COPR_LOGIN }} |
| 78 | + COPR_USERNAME: ${{ secrets.COPR_USERNAME }} |
| 79 | + COPR_TOKEN: ${{ secrets.COPR_TOKEN }} |
| 80 | + COPR_URL: ${{ secrets.COPR_URL }} |
| 81 | + run: | |
| 82 | + missing=() |
| 83 | + [[ -z "$COPR_LOGIN" ]] && missing+=(COPR_LOGIN) |
| 84 | + [[ -z "$COPR_USERNAME" ]] && missing+=(COPR_USERNAME) |
| 85 | + [[ -z "$COPR_TOKEN" ]] && missing+=(COPR_TOKEN) |
| 86 | + [[ -z "$COPR_URL" ]] && missing+=(COPR_URL) |
| 87 | + if (( ${#missing[@]} > 0 )); then |
| 88 | + echo "Error: COPR secrets not set on this repo:" >&2 |
| 89 | + printf ' %s\n' "${missing[@]}" >&2 |
| 90 | + echo "Provision per RELEASING.md's COPR one-time-setup section." >&2 |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | + mkdir -p ~/.config |
| 94 | + # Use printf rather than heredoc to avoid YAML-indentation |
| 95 | + # leaking into the file (configparser treats indented lines |
| 96 | + # as continuations and rejects them). |
| 97 | + printf '[copr-cli]\nlogin = %s\nusername = %s\ntoken = %s\ncopr_url = %s\n' \ |
| 98 | + "$COPR_LOGIN" "$COPR_USERNAME" "$COPR_TOKEN" "$COPR_URL" \ |
| 99 | + > ~/.config/copr |
| 100 | + chmod 600 ~/.config/copr |
| 101 | +
|
| 102 | + - name: copr-cli build |
| 103 | + run: | |
| 104 | + srpm=$(ls "$HOME/rpmbuild/SRPMS/"qn-${{ steps.meta.outputs.version }}-1*.src.rpm) |
| 105 | + if [[ ! -f "$srpm" ]]; then |
| 106 | + echo "Error: SRPM not found at expected path under SRPMS/" >&2 |
| 107 | + exit 1 |
| 108 | + fi |
| 109 | + echo "Uploading $srpm to quicknode/qn..." |
| 110 | + # --enable-net=on so COPR's mock chroot can curl the prebuilt |
| 111 | + # tarball + sha256 sidecar from the GitHub Release in %prep. |
| 112 | + copr-cli build quicknode/qn "$srpm" --enable-net=on |
0 commit comments