Skip to content

Commit f52a23e

Browse files
wip
1 parent 3c43950 commit f52a23e

File tree

5 files changed

+117
-20
lines changed

5 files changed

+117
-20
lines changed

.github/workflows/aur_upload.yml

+62-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
name: Upload AUR
2-
3-
on:
4-
release:
5-
types: [created]
2+
on: push
3+
#on:
4+
# release:
5+
# types: [created]
66

77
jobs:
8-
build:
8+
tpi-bin:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout Code
1212
uses: actions/checkout@v4
1313
- name: generate PKGBUILD
1414
run: |
15-
cp scripts/ci/PKGBUILD .
16-
PACKAGE_NAME=$(grep '^name =' Cargo.toml | sed 's/name = "\(.*\)"/\1/')
15+
cp scripts/ci/PKGBUILD.bin ./PKGBUILD
16+
PACKAGE_NAME=$(grep '^name =' Cargo.toml | sed 's/name = "\(.*\)"/\1/')-bin
1717
VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
1818
MAINTAINER=$(grep '^authors =' Cargo.toml | sed 's/authors = \[\s*"\(.*\)\s*"\]/\1/')
1919
DESCRIPTION=$(grep '^description =' Cargo.toml | sed 's/description = "\(.*\)"/\1/')
@@ -37,3 +37,58 @@ jobs:
3737
commit_email: 'noreply@turingpi.com'
3838
ssh_private_key: ${{ secrets.AUR_DEPLOY_KEY }}
3939
commit_message: Update package to ${{ env.VERSION }}
40+
41+
tpi-src:
42+
runs-on: ubuntu-latest
43+
strategy:
44+
matrix:
45+
name:
46+
- master
47+
- git
48+
steps:
49+
- name: Checkout Code
50+
uses: actions/checkout@v4
51+
- name: generate PKGBUILD
52+
run: |
53+
cp scripts/ci/PKGBUILD ./PKGBUILD
54+
PACKAGE_NAME=$(grep '^name =' Cargo.toml | sed 's/name = "\(.*\)"/\1/')
55+
VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
56+
MAINTAINER=$(grep '^authors =' Cargo.toml | sed 's/authors = \[\s*"\(.*\)\s*"\]/\1/')
57+
DESCRIPTION=$(grep '^description =' Cargo.toml | sed 's/description = "\(.*\)"/\1/')
58+
if [[ ${{ matrix.name }} == "master" ]]; then
59+
TAG=""
60+
PACKAGE_NAME=${PACKAGE_NAME}-git
61+
else
62+
TAG="#tag=v${VERSION}"
63+
fi
64+
sed -i "1i # Maintainer: ${MAINTAINER}" PKGBUILD
65+
sed -i "2i pkgname=${PACKAGE_NAME}" PKGBUILD
66+
sed -i "3i pkgver=${VERSION}" PKGBUILD
67+
sed -i "4i pkgdesc='${DESCRIPTION}'" PKGBUILD
68+
sed -i "5i source=(\"git+https://github.com/turing-machines/tpi.git${TAG}\")" PKGBUILD
69+
70+
install=$(cat scripts/ci/install)
71+
echo "package() {" >> PKGBUILD
72+
echo " TARGET=\$CARCH-unknown-linux-gnu" >> PKGBUILD
73+
echo "$install" >> PKGBUILD
74+
echo -e "}\n" >> PKGBUILD
75+
76+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
77+
echo "PKG_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV
78+
- run: cat ./PKGBUILD
79+
- name: Create AUR package
80+
uses: addnab/docker-run-action@v3
81+
with:
82+
registry: ghcr.io
83+
image: 'ghcr.io/heyhusen/archlinux-package-action:latest'
84+
options: -v ${{ github.workspace }}:/workspace --entrypoint=""
85+
run: /workspace/scripts/ci/entry_point.sh
86+
- name: Publish AUR package
87+
uses: KSXGitHub/github-actions-deploy-aur@v3
88+
with:
89+
pkgname: ${{ env.PKG_NAME }}
90+
pkgbuild: ./PKGBUILD
91+
commit_username: 'Github automation'
92+
commit_email: 'noreply@turingpi.com'
93+
ssh_private_key: ${{ secrets.AUR_DEPLOY_KEY }}
94+
commit_message: Update package to ${{ env.VERSION }}

scripts/ci/PKGBUILD

+22-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
pkgname=
2-
pkgver=
3-
pkgrel=1
4-
pkgdesc=
1+
pkgrel=3
52
url=https://turingpi.com/
6-
license=('Apache')
7-
arch=('x86_64' 'aarch64')
8-
source_x86_64=("https://github.com/turing-machines/tpi/releases/download/v${pkgver}/tpi-x86_64-unknown-linux-gnu.tar.gz")
9-
source_aarch64=("https://github.com/turing-machines/tpi/releases/download/v${pkgver}/tpi-aarch64-unknown-linux-gnu.tar.gz")
3+
license=('Apache-2.0')
4+
makedepends=('cargo' 'git')
5+
arch=('x86_64' 'aarch64' 'armv7h')
6+
options=(!lto)
107

11-
package() {
12-
tar -xzf "${srcdir}/tpi-${CARCH}-unknown-linux-gnu.tar.gz" -C "${pkgdir}"
8+
prepare() {
9+
cd tpi
10+
export RUSTUP_TOOLCHAIN=stable
11+
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
12+
}
13+
14+
build() {
15+
cd tpi
16+
export RUSTUP_TOOLCHAIN=stable
17+
export CARGO_TARGET_DIR=target
18+
cargo build --frozen --release --target "$CARCH-unknown-linux-gnu"
19+
}
20+
21+
check() {
22+
cd tpi
23+
export RUSTUP_TOOLCHAIN=stable
24+
cargo test --frozen
1325
}

scripts/ci/PKGBUILD.bin

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pkgname=
2+
pkgver=
3+
pkgrel=1
4+
pkgdesc=
5+
url=https://turingpi.com/
6+
license=('Apache-2.0')
7+
arch=('x86_64' 'aarch64')
8+
source_x86_64=("https://github.com/turing-machines/tpi/releases/download/v${pkgver}/tpi-x86_64-unknown-linux-gnu.tar.gz")
9+
source_aarch64=("https://github.com/turing-machines/tpi/releases/download/v${pkgver}/tpi-aarch64-unknown-linux-gnu.tar.gz")
10+
11+
package() {
12+
tar -xzf "${srcdir}/tpi-${CARCH}-unknown-linux-gnu.tar.gz" -C "${pkgdir}"
13+
}

scripts/ci/entry_point.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
work_dir=/home/builder/gh-action
3+
4+
echo "::group::Copying files from /workspace to $work_dir"
5+
mkdir -p $work_dir
6+
cp -rfv /workspace/* $work_dir
7+
cd $work_dir
8+
echo "::endgroup::"
9+
10+
echo "::group::Updating PKGBUID"
11+
updpkgsums
12+
makepkg -g >> PKGBUILD
13+
makepkg --printsrcinfo >.SRCINFO
14+
15+
sudo cp -f PKGBUILD /workspace
16+
sudo cp -f .SRCINFO /workspace
17+
echo "::endgroup::"

scripts/ci/install

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mkdir -p ${pkgdir}/usr/bin
22
mkdir -p ${pkgdir}/usr/share/doc/tpi
3-
install -m 755 ${srcdir}/target/${TARGET}/release/tpi ${pkgdir}/usr/bin/tpi
4-
install -m 644 ${srcdir}/README.md ${pkgdir}/usr/share/doc/tpi/README.md
5-
install -m 644 ${srcdir}/LICENSE ${pkgdir}/usr/share/doc/tpi/copyright
3+
install -m 755 ${srcdir}/tpi/target/${TARGET}/release/tpi ${pkgdir}/usr/bin/tpi
4+
install -m 644 ${srcdir}/tpi/README.md ${pkgdir}/usr/share/doc/tpi/README.md
5+
install -m 644 ${srcdir}/tpi/LICENSE ${pkgdir}/usr/share/doc/tpi/copyright
66

0 commit comments

Comments
 (0)