Skip to content

Commit 07e3bfe

Browse files
CI: updated AUR package flavors (#36)
On release, the following AUR packages are generated and pushed: * tpi -> latest stable release. build from a version tag * tpi-git -> trunk build from master * tpi-bin -> prebuild binary release
1 parent 87e67c1 commit 07e3bfe

File tree

7 files changed

+122
-20
lines changed

7 files changed

+122
-20
lines changed

.github/workflows/aur_upload.yml

+66-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
name: Upload AUR
2-
32
on:
43
release:
54
types: [created]
65

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

.github/workflows/release.yml

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
steps:
3333
- name: Checkout Code
3434
uses: actions/checkout@v4
35-
with:
36-
fetch-depth: 1
3735

3836
- name: Install Toolchain
3937
uses: actions-rs/toolchain@v1

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "tpi"
33
version = "1.0.7"
44
edition = "2021"
55
license = "Apache-2.0"
6-
authors = ["Sven Rademakers <sven@turingpi.com>"]
6+
authors = ["Sven Rademakers <sven.rademakers@gmail.com>"]
77
description = "Official Turing-Pi2 CLI tool"
88
homepage = "https://turingpi.com/"
99
repository = "https://github.com/turing-machines/tpi"

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}/${pkgname}/target/${TARGET}/release/tpi ${pkgdir}/usr/bin/tpi
4+
install -m 644 ${srcdir}/${pkgname}/README.md ${pkgdir}/usr/share/doc/tpi/README.md
5+
install -m 644 ${srcdir}/${pkgname}/LICENSE ${pkgdir}/usr/share/doc/tpi/copyright
66

0 commit comments

Comments
 (0)