From de4f8ae091088522218f4467af83bdc030257a3a Mon Sep 17 00:00:00 2001 From: Sven Rademakers Date: Tue, 12 Nov 2024 15:03:27 +0000 Subject: [PATCH] wip --- .github/workflows/aur_upload.yml | 81 +++++++++++++++++++++++++++----- scripts/ci/PKGBUILD | 27 +++++++---- scripts/ci/PKGBUILD.bin | 13 +++++ scripts/ci/entry_point.sh | 17 +++++++ scripts/ci/install | 6 +-- 5 files changed, 120 insertions(+), 24 deletions(-) create mode 100644 scripts/ci/PKGBUILD.bin create mode 100644 scripts/ci/entry_point.sh diff --git a/.github/workflows/aur_upload.yml b/.github/workflows/aur_upload.yml index 3df72c1..e3ce435 100644 --- a/.github/workflows/aur_upload.yml +++ b/.github/workflows/aur_upload.yml @@ -1,33 +1,88 @@ name: Upload AUR - -on: - release: - types: [created] +on: push +#on: +# release: +# types: [created] jobs: - build: + # tpi-bin: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # - name: generate PKGBUILD + # run: | + # cp scripts/ci/PKGBUILD.bin ./PKGBUILD + # PACKAGE_NAME=$(grep '^name =' Cargo.toml | sed 's/name = "\(.*\)"/\1/')-bin + # 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 }} + + tpi-src: runs-on: ubuntu-latest + strategy: + matrix: + name: + - master + - git steps: - name: Checkout Code uses: actions/checkout@v4 - name: generate PKGBUILD run: | - cp scripts/ci/PKGBUILD . + cp scripts/ci/PKGBUILD ./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/') + if [[ ${{ matrix.name }} == "master" ]]; then + TAG="" + PACKAGE_NAME=${PACKAGE_NAME}-git + else + TAG="#tag=v${VERSION}" + fi 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 + sed -i "2i pkgname=${PACKAGE_NAME}" PKGBUILD + sed -i "3i pkgver=${VERSION}" PKGBUILD + sed -i "4i pkgdesc='${DESCRIPTION}'" PKGBUILD + sed -i "5i source=(\"git+https://github.com/turing-machines/tpi.git${TAG}\")" PKGBUILD + + install=$(cat scripts/ci/install) + echo "package() {" >> PKGBUILD + echo " TARGET=\$CARCH-unknown-linux-gnu" >> PKGBUILD + echo "$install" >> PKGBUILD + echo -e "}\n" >> PKGBUILD + echo "VERSION=${VERSION}" >> $GITHUB_ENV echo "PKG_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV - - name: Validate package - uses: heyhusen/archlinux-package-action@v2 + - run: cat ./PKGBUILD + - name: Create AUR package + uses: addnab/docker-run-action@v3 with: - updpkgsums: true - srcinfo: true + registry: ghcr.io + image: 'ghcr.io/heyhusen/archlinux-package-action:latest' + options: -v ${{ github.workspace }}:/workspace --entrypoint="" + run: /workspace/scripts/ci/entry_point.sh - name: Publish AUR package uses: KSXGitHub/github-actions-deploy-aur@v3 with: diff --git a/scripts/ci/PKGBUILD b/scripts/ci/PKGBUILD index b07815d..e493bf7 100644 --- a/scripts/ci/PKGBUILD +++ b/scripts/ci/PKGBUILD @@ -1,13 +1,24 @@ -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") +makedepends=('cargo') +arch=('any') -package() { - tar -xzf "${srcdir}/tpi-${CARCH}-unknown-linux-gnu.tar.gz" -C "${pkgdir}" +prepare() { + cd tpi + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target "$CARCH-unknown-linux-gnu" +} + +build() { + cd tpi + export RUSTUP_TOOLCHAIN=stable + export CARGO_TARGET_DIR=target + cargo build --frozen --release --target "$CARCH-unknown-linux-gnu" +} + +check() { + cd tpi + export RUSTUP_TOOLCHAIN=stable + cargo test --frozen } diff --git a/scripts/ci/PKGBUILD.bin b/scripts/ci/PKGBUILD.bin new file mode 100644 index 0000000..b07815d --- /dev/null +++ b/scripts/ci/PKGBUILD.bin @@ -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}" +} diff --git a/scripts/ci/entry_point.sh b/scripts/ci/entry_point.sh new file mode 100644 index 0000000..0d8e540 --- /dev/null +++ b/scripts/ci/entry_point.sh @@ -0,0 +1,17 @@ +#!/bin/bash +work_dir=/home/builder/gh-action + +echo "::group::Copying files from /workspace to $work_dir" +mkdir -p $work_dir +cp -rfv /workspace/* $work_dir +cd $work_dir +echo "::endgroup::" + +echo "::group::Updating PKGBUID" +updpkgsums +makepkg -g >> PKGBUILD +makepkg --printsrcinfo >.SRCINFO + +sudo cp -f PKGBUILD /workspace +sudo cp -f .SRCINFO /workspace +echo "::endgroup::" diff --git a/scripts/ci/install b/scripts/ci/install index 90c46b7..6bc70e5 100644 --- a/scripts/ci/install +++ b/scripts/ci/install @@ -1,6 +1,6 @@ mkdir -p ${pkgdir}/usr/bin mkdir -p ${pkgdir}/usr/share/doc/tpi -install -m 755 ${srcdir}/target/${TARGET}/release/tpi ${pkgdir}/usr/bin/tpi -install -m 644 ${srcdir}/README.md ${pkgdir}/usr/share/doc/tpi/README.md -install -m 644 ${srcdir}/LICENSE ${pkgdir}/usr/share/doc/tpi/copyright +install -m 755 ${srcdir}/${pkgname}/target/${TARGET}/release/tpi ${pkgdir}/usr/bin/tpi +install -m 644 ${srcdir}/${pkgname}/README.md ${pkgdir}/usr/share/doc/tpi/README.md +install -m 644 ${srcdir}/${pkgname}/LICENSE ${pkgdir}/usr/share/doc/tpi/copyright