Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/copr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build in COPR

# On a published release, build the source RPM (version taken from the tag)
# in a Fedora container and submit it to COPR (thesapd/headsetcontrol), which
# builds the binary RPMs for the configured Fedora/EPEL chroots.
#
# Requires a repository secret COPR_API_TOKEN: the full contents of your
# COPR API config (from https://copr.fedorainfracloud.org/api/), i.e. the
# `[copr-cli]` block with login/username/token/copr_url.
on:
release:
types: [published]
Comment on lines +11 to +12

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Trigger COPR after the GITHUB_TOKEN-created release

The repository's normal release path will not invoke this workflow: .github/workflows/release.yml creates the published release through ncipollo/release-action using secrets.GITHUB_TOKEN (lines 88-101), and GitHub does not start subsequent workflows for events caused by that token (other than its documented dispatch exceptions). Consequently, pushing a normal version tag produces the GitHub release but never submits its SRPM to COPR; only a manually created release or workflow_dispatch will run this job. Trigger this from the tag/release workflow directly (or use an appropriate non-GITHUB_TOKEN trigger mechanism).

Useful? React with 👍 / 👎.

workflow_dispatch:
inputs:
tag:
description: "Release tag to build (e.g. 4.1.0)"
required: true
type: string

permissions:
contents: read

jobs:
copr:
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: ${{ github.event.release.tag_name || inputs.tag }}

- name: Write COPR config
env:
COPR_CONFIG: ${{ secrets.COPR_API_TOKEN }}
run: |
mkdir -p copr-cfg
printf '%s' "$COPR_CONFIG" > copr-cfg/copr

- name: Build SRPM and submit to COPR
run: |
docker run --rm -v "$PWD":/src -w /src -e TAG fedora:latest \
bash -euo pipefail -c '
dnf install -y -q rpm-build rpmdevtools copr-cli
rpmdev-setuptree
# Inject the release version (Source0 tracks %{version})
sed -i "s/^Version:.*/Version: ${TAG}/" headsetcontrol.spec
cp headsetcontrol.spec ~/rpmbuild/SPECS/
spectool -g -R ~/rpmbuild/SPECS/headsetcontrol.spec
rpmbuild -bs ~/rpmbuild/SPECS/headsetcontrol.spec
mkdir -p ~/.config && cp /src/copr-cfg/copr ~/.config/copr
copr-cli build --nowait thesapd/headsetcontrol ~/rpmbuild/SRPMS/*.src.rpm
'
Loading