mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
pkg: Generate Spec Files for COPR on Release Publish (#406)
* COPR spec generation * clean up testing specs, add autogenerated spec warning md file * fix github release event var references * coerce release url from other vars * add extra config for hitting copr webhook on chore pr merge * Address PR feedback * initial set of spec files * fix: include rust in spec BuildRequires --------- Co-authored-by: Ilya Zlobintsev <ilya.zl@protonmail.com>
This commit is contained in:
parent
3e53e0336e
commit
0ac9d3b46b
62
.github/workflows/generate-fedora-spec.yaml
vendored
Normal file
62
.github/workflows/generate-fedora-spec.yaml
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
name: generate-fedora-spec
|
||||
|
||||
on:
|
||||
release:
|
||||
types: ["published"]
|
||||
|
||||
jobs:
|
||||
generate-spec:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install yq
|
||||
run: |
|
||||
sudo curl -L https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 -o /usr/local/bin/yq
|
||||
sudo chmod +x /usr/local/bin/yq
|
||||
- name: Verify yq installation
|
||||
run: yq --version
|
||||
- name: Install rpmlint
|
||||
run: sudo apt-get install -y rpmlint
|
||||
- name: Generate spec files
|
||||
run: ./pkg/bin/generate_spec.sh
|
||||
env:
|
||||
GH_RELEASE_NAME: ${{ github.event.release.name }}
|
||||
GH_RELEASE_TAG: ${{ github.event.release.tag_name }}
|
||||
GH_REPO_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}
|
||||
- name: Validate generated spec files
|
||||
run: |
|
||||
for spec_file in pkg/fedora-spec/*.spec; do
|
||||
echo "Validating $spec_file"
|
||||
rpmlint $spec_file || exit 1
|
||||
done
|
||||
- name: Create Branch and Commit Changes
|
||||
run: |
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
branch_name="chore/update-spec-files-${{ github.event.release.tag_name }}"
|
||||
git checkout -b $branch_name
|
||||
git add pkg/fedora-spec/*.spec
|
||||
git commit -m "chore: Update spec files for release ${{ github.event.release.tag_name }}"
|
||||
git push origin $branch_name
|
||||
- name: Create Pull Request
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const { repo, owner } = context.repo;
|
||||
const result = await github.rest.pulls.create({
|
||||
owner,
|
||||
repo,
|
||||
title: `chore: Update spec files for release ${process.env.RELEASE_TAG}`,
|
||||
body: `Automated PR to update spec files following release ${process.env.RELEASE_TAG}`,
|
||||
head: `chore/update-spec-files-${process.env.RELEASE_TAG}`,
|
||||
base: 'master'
|
||||
});
|
||||
await github.rest.issues.addLabels({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: result.data.number,
|
||||
labels: ['copr-update']
|
||||
});
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
18
.github/workflows/trigger-copr.yaml
vendored
Normal file
18
.github/workflows/trigger-copr.yaml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: trigger-copr
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
paths:
|
||||
- "**.spec"
|
||||
|
||||
jobs:
|
||||
trigger-copr:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.merged == true
|
||||
steps:
|
||||
- name: Trigger COPR Webhook
|
||||
if: steps.check-labels.outputs.trigger == 'true'
|
||||
run: |
|
||||
curl -X POST ${{ secrets.COPR_WEBHOOK_URL }}
|
103
pkg/bin/generate_spec.sh
Executable file
103
pkg/bin/generate_spec.sh
Executable file
@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
|
||||
extract_changelog() {
|
||||
local spec_file="$1"
|
||||
if [ -f "$spec_file" ]; then
|
||||
sed -n '/%changelog/,$p' "$spec_file" | sed '1d'
|
||||
fi
|
||||
}
|
||||
|
||||
if ! command -v yq &>/dev/null; then
|
||||
echo "yq not found. Please install yq to proceed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RECIPES_DIR="pkg/recipes"
|
||||
SPEC_OUTPUT_DIR="pkg/fedora-spec"
|
||||
mkdir -p $SPEC_OUTPUT_DIR
|
||||
|
||||
for RECIPE_PATH in "$RECIPES_DIR"/*/; do
|
||||
RECIPE_NAME=$(basename "$RECIPE_PATH")
|
||||
RECIPE_FILE="${RECIPE_PATH}recipe.yml"
|
||||
|
||||
if [ ! -f "$RECIPE_FILE" ]; then
|
||||
echo "No recipe.yml found in $RECIPE_PATH, skipping."
|
||||
continue
|
||||
fi
|
||||
|
||||
RECIPE_VERSION=$(yq eval '.metadata.version // "0.0.1"' "$RECIPE_FILE")
|
||||
RECIPE_RELEASE=1
|
||||
PKG_LICENSE=$(yq eval '.metadata.license // "UNKNOWN"' "$RECIPE_FILE")
|
||||
PKG_DESCRIPTION=$(yq eval '.metadata.description // "No description available."' "$RECIPE_FILE")
|
||||
MAINTAINER=$(yq eval '.metadata.maintainer // "Unknown Maintainer"' "$RECIPE_FILE")
|
||||
SOURCE_URL="https://github.com/ilya-zlobintsev/LACT/archive/refs/tags/v${RECIPE_VERSION}.tar.gz"
|
||||
|
||||
# Collect Fedora-specific dependencies safely
|
||||
PKG_DEPENDS=$(yq eval '.metadata.depends | with_entries(select(.key | contains("fedora"))) | .[] | join(" ")' "$RECIPE_FILE" | xargs)
|
||||
PKG_BUILD_DEPENDS=$(yq eval '.metadata.build_depends | with_entries(select(.key | contains("fedora"))) | .[] | join(" ")' "$RECIPE_FILE" | xargs)
|
||||
|
||||
# Include dependencies from the 'all' key if they exist
|
||||
ALL_DEPENDS=$(yq eval 'select(.metadata.depends.all != null) | .metadata.depends.all | join(" ")' "$RECIPE_FILE" | xargs)
|
||||
ALL_BUILD_DEPENDS=$(yq eval 'select(.metadata.build_depends.all != null) | .metadata.build_depends.all | join(" ")' "$RECIPE_FILE" | xargs)
|
||||
|
||||
PKG_DEPENDS="${PKG_DEPENDS} ${ALL_DEPENDS}"
|
||||
PKG_BUILD_DEPENDS="${PKG_BUILD_DEPENDS} ${ALL_BUILD_DEPENDS}"
|
||||
|
||||
# Trim any leading or trailing whitespace
|
||||
PKG_DEPENDS=$(echo "$PKG_DEPENDS" | xargs)
|
||||
PKG_BUILD_DEPENDS=$(echo "$PKG_BUILD_DEPENDS" | xargs)
|
||||
|
||||
# Generate the spec file
|
||||
SPEC_FILE="${SPEC_OUTPUT_DIR}/${RECIPE_NAME}.spec"
|
||||
|
||||
EXISTING_CHANGELOG=""
|
||||
if [ -f "$SPEC_FILE" ]; then
|
||||
EXISTING_CHANGELOG=$(extract_changelog "$SPEC_FILE")
|
||||
fi
|
||||
# For proper date formatting consistent with other builds.
|
||||
export LC_ALL=c
|
||||
cat <<EOF >"$SPEC_FILE"
|
||||
Name: $RECIPE_NAME
|
||||
Version: $RECIPE_VERSION
|
||||
Release: $RECIPE_RELEASE
|
||||
Summary: $PKG_DESCRIPTION
|
||||
License: $PKG_LICENSE
|
||||
URL: https://github.com/ilya-zlobintsev/LACT
|
||||
Source0: $SOURCE_URL
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: rust cargo $PKG_BUILD_DEPENDS
|
||||
Requires: $PKG_DEPENDS
|
||||
|
||||
%description
|
||||
$PKG_DESCRIPTION
|
||||
|
||||
%prep
|
||||
%setup -q -n LACT-%{version}
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make install PREFIX=/usr DESTDIR=%{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
/usr/bin/$RECIPE_NAME
|
||||
/usr/lib/systemd/system/${RECIPE_NAME}d.service
|
||||
/usr/share/applications/io.github.$RECIPE_NAME-linux.desktop
|
||||
/usr/share/icons/hicolor/scalable/apps/io.github.$RECIPE_NAME-linux.svg
|
||||
/usr/share/pixmaps/io.github.$RECIPE_NAME-linux.png
|
||||
|
||||
%changelog
|
||||
* $(date +"%a %b %d %Y") - $MAINTAINER - $GH_RELEASE_NAME - $GH_RELEASE_TAG
|
||||
- Autogenerated from CI, please see $GH_RELEASE_URL for detailed changelog.
|
||||
${EXISTING_CHANGELOG}
|
||||
EOF
|
||||
|
||||
echo "Spec file created at $SPEC_FILE"
|
||||
cat "$SPEC_FILE"
|
||||
done
|
3
pkg/fedora-spec/AUTOGENERATED.md
Normal file
3
pkg/fedora-spec/AUTOGENERATED.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Warning!
|
||||
|
||||
All spec files in this directory are autogenerated, and should not be edited manually.
|
39
pkg/fedora-spec/lact-headless.spec
Normal file
39
pkg/fedora-spec/lact-headless.spec
Normal file
@ -0,0 +1,39 @@
|
||||
Name: lact-headless
|
||||
Version: 0.5.6
|
||||
Release: 1
|
||||
Summary: AMDGPU control utility
|
||||
License: MIT
|
||||
URL: https://github.com/ilya-zlobintsev/LACT
|
||||
Source0: https://github.com/ilya-zlobintsev/LACT/archive/refs/tags/v0.5.6.tar.gz
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: rust cargo gcc libdrm-devel dbus curl make clang git
|
||||
Requires: libdrm hwdata
|
||||
|
||||
%description
|
||||
AMDGPU control utility
|
||||
|
||||
%prep
|
||||
%setup -q -n LACT-%{version}
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make install PREFIX=/usr DESTDIR=%{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
/usr/bin/lact-headless
|
||||
/usr/lib/systemd/system/lact-headlessd.service
|
||||
/usr/share/applications/io.github.lact-headless-linux.desktop
|
||||
/usr/share/icons/hicolor/scalable/apps/io.github.lact-headless-linux.svg
|
||||
/usr/share/pixmaps/io.github.lact-headless-linux.png
|
||||
|
||||
%changelog
|
||||
* Thu Nov 14 2024 - ilya-zlobintsev - -
|
||||
- Autogenerated from CI, please see for detailed changelog.
|
||||
|
39
pkg/fedora-spec/lact-libadwaita.spec
Normal file
39
pkg/fedora-spec/lact-libadwaita.spec
Normal file
@ -0,0 +1,39 @@
|
||||
Name: lact-libadwaita
|
||||
Version: 0.5.6
|
||||
Release: 1
|
||||
Summary: AMDGPU control utility
|
||||
License: MIT
|
||||
URL: https://github.com/ilya-zlobintsev/LACT
|
||||
Source0: https://github.com/ilya-zlobintsev/LACT/archive/refs/tags/v0.5.6.tar.gz
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: rust cargo gtk4-devel gcc libdrm-devel blueprint-compiler libadwaita-devel dbus curl make clang git
|
||||
Requires: gtk4 libdrm libadwaita hwdata
|
||||
|
||||
%description
|
||||
AMDGPU control utility
|
||||
|
||||
%prep
|
||||
%setup -q -n LACT-%{version}
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make install PREFIX=/usr DESTDIR=%{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
/usr/bin/lact-libadwaita
|
||||
/usr/lib/systemd/system/lact-libadwaitad.service
|
||||
/usr/share/applications/io.github.lact-libadwaita-linux.desktop
|
||||
/usr/share/icons/hicolor/scalable/apps/io.github.lact-libadwaita-linux.svg
|
||||
/usr/share/pixmaps/io.github.lact-libadwaita-linux.png
|
||||
|
||||
%changelog
|
||||
* Thu Nov 14 2024 - ilya-zlobintsev - -
|
||||
- Autogenerated from CI, please see for detailed changelog.
|
||||
|
39
pkg/fedora-spec/lact.spec
Normal file
39
pkg/fedora-spec/lact.spec
Normal file
@ -0,0 +1,39 @@
|
||||
Name: lact
|
||||
Version: 0.5.6
|
||||
Release: 1
|
||||
Summary: AMDGPU control utility
|
||||
License: MIT
|
||||
URL: https://github.com/ilya-zlobintsev/LACT
|
||||
Source0: https://github.com/ilya-zlobintsev/LACT/archive/refs/tags/v0.5.6.tar.gz
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: rust cargo gtk4-devel gcc libdrm-devel blueprint-compiler dbus curl make clang git
|
||||
Requires: gtk4 libdrm hwdata
|
||||
|
||||
%description
|
||||
AMDGPU control utility
|
||||
|
||||
%prep
|
||||
%setup -q -n LACT-%{version}
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make install PREFIX=/usr DESTDIR=%{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
/usr/bin/lact
|
||||
/usr/lib/systemd/system/lactd.service
|
||||
/usr/share/applications/io.github.lact-linux.desktop
|
||||
/usr/share/icons/hicolor/scalable/apps/io.github.lact-linux.svg
|
||||
/usr/share/pixmaps/io.github.lact-linux.png
|
||||
|
||||
%changelog
|
||||
* Thu Nov 14 2024 - ilya-zlobintsev - -
|
||||
- Autogenerated from CI, please see for detailed changelog.
|
||||
|
Loading…
Reference in New Issue
Block a user