From 3278fee1a1a750b8b7ec02d0f6749c87769c0f4f Mon Sep 17 00:00:00 2001 From: Sven Rademakers Date: Mon, 4 Nov 2024 18:25:47 +0000 Subject: [PATCH] Added workflow that pushes new releases to AUR --- .github/workflows/aur_upload.yml | 39 ++++++++++++++++ build.rs | 76 -------------------------------- scripts/ci/PKGBUILD | 13 ++++++ 3 files changed, 52 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/aur_upload.yml delete mode 100644 build.rs create mode 100644 scripts/ci/PKGBUILD diff --git a/.github/workflows/aur_upload.yml b/.github/workflows/aur_upload.yml new file mode 100644 index 0000000..3df72c1 --- /dev/null +++ b/.github/workflows/aur_upload.yml @@ -0,0 +1,39 @@ +name: Upload AUR + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: generate PKGBUILD + run: | + cp scripts/ci/PKGBUILD . + PACKAGE_NAME=$(grep '^name =' Cargo.toml | sed 's/name = "\(.*\)"/\1/') + VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/') + MAINTAINER=$(grep '^authors =' Cargo.toml | sed 's/authors = \[\s*"\(.*\)\s*"\]/\1/') + DESCRIPTION=$(grep '^description =' Cargo.toml | sed 's/description = "\(.*\)"/\1/') + sed -i "1i # Maintainer: ${MAINTAINER}" PKGBUILD + sed -i "s/^pkgname=.*/pkgname=${PACKAGE_NAME}/" PKGBUILD + sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD + sed -i "s/^pkgdesc=.*/pkgdesc='${DESCRIPTION}'/" PKGBUILD + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "PKG_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV + - name: Validate package + uses: heyhusen/archlinux-package-action@v2 + with: + updpkgsums: true + srcinfo: true + - name: Publish AUR package + uses: KSXGitHub/github-actions-deploy-aur@v3 + with: + pkgname: ${{ env.PKG_NAME }} + pkgbuild: ./PKGBUILD + commit_username: 'Github automation' + commit_email: 'noreply@turingpi.com' + ssh_private_key: ${{ secrets.AUR_DEPLOY_KEY }} + commit_message: Update package to ${{ env.VERSION }} diff --git a/build.rs b/build.rs deleted file mode 100644 index 174daec..0000000 --- a/build.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Turing Machines -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::fs::File; -use std::io::Write; -use std::{env, io}; - -fn main() -> io::Result<()> { - generate_pgkbuild() -} - -fn generate_pgkbuild() -> io::Result<()> { - let pkg_name = format!("{}-{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")); - let mut pkgbuild = File::create(format!("{}/PKGBUILD", std::env::var("OUT_DIR").unwrap()))?; - writeln!(pkgbuild, "# Maintainer: {}\n", env!("CARGO_PKG_AUTHORS"))?; - writeln!(pkgbuild, "pkgname={}", env!("CARGO_PKG_NAME"))?; - writeln!(pkgbuild, "pkgver={}", env!("CARGO_PKG_VERSION"))?; - writeln!(pkgbuild, "pkgrel=1")?; - writeln!(pkgbuild, "pkgdesc='{}'", env!("CARGO_PKG_DESCRIPTION"))?; - writeln!(pkgbuild, "url={}", env!("CARGO_PKG_HOMEPAGE"))?; - writeln!(pkgbuild, "license=('Apache')")?; - writeln!(pkgbuild, "makedepends=('cargo')")?; - writeln!(pkgbuild, "arch=('any')")?; - writeln!( - pkgbuild, - r"source=('{}/archive/refs/tags/v{}.tar.gz')", - env!("CARGO_PKG_REPOSITORY"), - env!("CARGO_PKG_VERSION") - )?; - writeln!( - pkgbuild, - r#"prepare() {{ - cd $srcdir/{} - export RUSTUP_TOOLCHAIN=stable - cargo fetch --locked --target "$CARCH-unknown-linux-gnu" -}} -"#, - pkg_name - )?; - writeln!( - pkgbuild, - r#"build() {{ - export RUSTUP_TOOLCHAIN=stable - export CARGO_TARGET_DIR=target - cd $srcdir/{} && cargo build --frozen --release -}}"#, - pkg_name - )?; - writeln!( - pkgbuild, - r#"check() {{ - export RUSTUP_TOOLCHAIN=stable - cd $srcdir/{} && cargo test --frozen -}}"#, - pkg_name - )?; - writeln!( - pkgbuild, - r#"package() {{ - install -Dm0755 -t "$pkgdir/usr/bin/" "$srcdir/{}/target/release/{}" -}}"#, - pkg_name, - env!("CARGO_PKG_NAME") - ) -} diff --git a/scripts/ci/PKGBUILD b/scripts/ci/PKGBUILD new file mode 100644 index 0000000..b07815d --- /dev/null +++ b/scripts/ci/PKGBUILD @@ -0,0 +1,13 @@ +pkgname= +pkgver= +pkgrel=1 +pkgdesc= +url=https://turingpi.com/ +license=('Apache') +arch=('x86_64' 'aarch64') +source_x86_64=("https://github.com/turing-machines/tpi/releases/download/v${pkgver}/tpi-x86_64-unknown-linux-gnu.tar.gz") +source_aarch64=("https://github.com/turing-machines/tpi/releases/download/v${pkgver}/tpi-aarch64-unknown-linux-gnu.tar.gz") + +package() { + tar -xzf "${srcdir}/tpi-${CARCH}-unknown-linux-gnu.tar.gz" -C "${pkgdir}" +}