diff --git a/.github/workflows/hook_copr.yml b/.github/workflows/hook_copr.yml new file mode 100644 index 000000000..c7b6b8d79 --- /dev/null +++ b/.github/workflows/hook_copr.yml @@ -0,0 +1,73 @@ +name: Trigger COPR build + +on: + workflow_call: + secrets: + COPR_HOOK_DAILY: + COPR_HOOK_ALPHA: + COPR_HOOK_BETA: + inputs: + copr_project: + description: COPR project to target + required: true + type: string + +permissions: read-all + +jobs: + build-copr-hook: + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + ref: ${{ github.ref }} + repository: ${{ github.repository }} + + - name: Install Python dependencies + run: | + pip install requests + + - name: Trigger COPR build + shell: python + run: | + import requests + + project_name = "${{ inputs.copr_project }}" + if project_name == "daily": + hook_secret = "${{ secrets.COPR_HOOK_DAILY }}" + project_id = 160277 + elif project_name == "alpha": + hook_secret = "${{ secrets.COPR_HOOK_ALPHA }}" + project_id = 160278 + elif project_name == "beta": + hook_secret = "${{ secrets.COPR_HOOK_BETA }}" + project_id = 160279 + else: + raise ValueError(f"Unknown COPR project: {project_name}") + + webhook_url = f"https://copr.fedorainfracloud.org/webhooks/github/{project_id}/{hook_secret}/meshtasticd/" + copr_payload = { + "event": "push", + "payload": { + "ref": "${{ github.ref }}", + "after": "${{ github.sha }}", + "repository": { + "id": "${{ github.repository_id }}", + "full_name": "${{ github.repository }}", + "git_url": "${{ github.repositoryUrl }}", + "owner": { + "name": "${{ github.repository_owner }}" + } + }, + "pusher": { + "name": "${{ github.actor }}" + }, + "sender": { + "login": "github-actions[bot]" + } + } + } + r = requests.post(webhook_url, json=copr_payload) + r.raise_for_status() diff --git a/.github/workflows/nightly_debian.yml b/.github/workflows/nightly_packaging.yml similarity index 75% rename from .github/workflows/nightly_debian.yml rename to .github/workflows/nightly_packaging.yml index aa001854e..e477fe194 100644 --- a/.github/workflows/nightly_debian.yml +++ b/.github/workflows/nightly_packaging.yml @@ -1,4 +1,4 @@ -name: Nightly Debian Packaging +name: Nightly Packaging on: schedule: - cron: 0 9 * * * @@ -8,10 +8,12 @@ on: - master paths: - debian/** - - .github/workflows/nightly_debian.yml + - "*.rpkg" + - .github/workflows/nightly_packaging.yml - .github/workflows/build_debian_src.yml - .github/workflows/package_ppa.yml - .github/workflows/package_obs.yml + - .github/workflows/hook_copr.yml permissions: contents: write @@ -35,3 +37,9 @@ jobs: obs_project: home:meshtastic:daily series: unstable secrets: inherit + + hook-copr: + uses: ./.github/workflows/hook_copr.yml + with: + copr_project: daily + secrets: inherit diff --git a/.github/workflows/release_channels.yml b/.github/workflows/release_channels.yml index 34673f0c7..8891826d2 100644 --- a/.github/workflows/release_channels.yml +++ b/.github/workflows/release_channels.yml @@ -27,3 +27,10 @@ jobs: series: |- ${{ contains(github.event.release.name, 'Beta') && 'beta' || contains(github.event.release.name, 'Alpha') && 'alpha' }} secrets: inherit + + # hook-copr: + # uses: ./.github/workflows/hook_copr.yml + # with: + # copr_project: |- + # ${{ contains(github.event.release.name, 'Beta') && 'beta' || contains(github.event.release.name, 'Alpha') && 'alpha' }} + # secrets: inherit diff --git a/bin/rpkg.macros b/bin/rpkg.macros new file mode 100644 index 000000000..2bbb203de --- /dev/null +++ b/bin/rpkg.macros @@ -0,0 +1,12 @@ +function meshtastic_version { + meshtastic_version=$(python3 bin/buildinfo.py short) + echo -n "$meshtastic_version" +} +function git_commits_num { + total_commits=$(git rev-list --all --count) + echo -n "$total_commits" +} +function git_commit_sha { + commit_sha=$(git rev-parse --short HEAD) + echo -n "$commit_sha" +} \ No newline at end of file diff --git a/meshtasticd.spec.rpkg b/meshtasticd.spec.rpkg new file mode 100644 index 000000000..1819897b0 --- /dev/null +++ b/meshtasticd.spec.rpkg @@ -0,0 +1,91 @@ +# meshtasticd spec file for RPM-based distributions +# +# Build locally with: +# ``` +# sudo dnf install rpkg-util +# rpkg local +# ``` +# +# See: +# - https://docs.pagure.org/rpkg-util/v3/index.html +# - https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/ + +Name: meshtasticd +# Version Ex: 2.5.19 +Version: {{{ meshtastic_version }}} +# Release Ex: 9127.daily.gitd7f5f620.fc41 +Release: {{{ git_commits_num }}}%{?copr_projectname:.%{copr_projectname}}.git{{{ git_commit_sha }}}%{?dist} +VCS: {{{ git_dir_vcs }}} +Summary: Meshtastic daemon for communicating with Meshtastic devices + +License: GPL-3.0 +URL: https://github.com/meshtastic/firmware +Source0: {{{ git_dir_pack }}} +Source1: https://github.com/meshtastic/web/releases/download/latest/build.tar + +BuildRequires: systemd-rpm-macros +BuildRequires: python3-devel +BuildRequires: platformio +BuildRequires: python3dist(protobuf) +BuildRequires: python3dist(grpcio[protobuf]) +BuildRequires: python3dist(grpcio-tools) +BuildRequires: git-core +BuildRequires: gcc-c++ +BuildRequires: pkgconfig(yaml-cpp) +BuildRequires: pkgconfig(libgpiod) +BuildRequires: pkgconfig(bluez) +BuildRequires: pkgconfig(libusb-1.0) +BuildRequires: libi2c-devel +# Web components: +BuildRequires: pkgconfig(openssl) +BuildRequires: pkgconfig(liborcania) +BuildRequires: pkgconfig(libyder) +BuildRequires: pkgconfig(libulfius) + +%description +Meshtastic daemon for controlling Meshtastic devices. Meshtastic is an off-grid +text communication platform that uses inexpensive LoRa radios. + +%prep +{{{ git_dir_setup_macro }}} +# Unpack the web files +mkdir -p web +tar -xf %{SOURCE1} -C web +gzip -dr web + +%build +# Use the “native” environment from platformio to build a Linux binary +platformio run -e native + +%install +mkdir -p %{buildroot}%{_sbindir} +install -m 0755 .pio/build/native/program %{buildroot}%{_sbindir}/meshtasticd + +mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd +install -m 0644 bin/config-dist.yaml %{buildroot}%{_sysconfdir}/meshtasticd/config.yaml +mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd/config.d +mkdir -p %{buildroot}%{_sysconfdir}/meshtasticd/available.d +cp -r bin/config.d/* %{buildroot}%{_sysconfdir}/meshtasticd/available.d + +install -D -m 0644 bin/meshtasticd.service %{buildroot}%{_unitdir}/meshtasticd.service + +# Install the web files under /usr/share/meshtasticd/web +mkdir -p %{buildroot}%{_datadir}/meshtasticd/web +cp -r web/* %{buildroot}%{_datadir}/meshtasticd/web + +%files +%license LICENSE +%doc README.md +%{_sbindir}/meshtasticd +%dir %{_sysconfdir}/meshtasticd +%dir %{_sysconfdir}/meshtasticd/config.d +%dir %{_sysconfdir}/meshtasticd/available.d +%config(noreplace) %{_sysconfdir}/meshtasticd/config.yaml +%config %{_sysconfdir}/meshtasticd/available.d/* +%{_unitdir}/meshtasticd.service +%dir %{_datadir}/meshtasticd +%dir %{_datadir}/meshtasticd/web +%{_datadir}/meshtasticd/web/* + +%changelog +%autochangelog \ No newline at end of file diff --git a/rpkg.conf b/rpkg.conf new file mode 100644 index 000000000..f574f9a13 --- /dev/null +++ b/rpkg.conf @@ -0,0 +1,2 @@ +[rpkg] +user_macros = "${git_props:root}/bin/rpkg.macros"