Skip to content

Commit 3b58e76

Browse files
committed
Start building out arch package
1 parent 9387c79 commit 3b58e76

4 files changed

Lines changed: 129 additions & 3 deletions

File tree

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,52 @@ jobs:
5555
name: rpm
5656
path: pkg/rpmbuild/RPMS/**/*.rpm
5757
retention-days: 1
58+
59+
# we use a ubuntu image here even just for the arch build because when we
60+
# bump the minimum to noble we can unify these two steps (makepkg/packman
61+
# are not in the jammy image but they are in the noble image)
62+
arch:
63+
runs-on: ubuntu-latest
64+
container:
65+
image: ubuntu:noble
66+
# needs: [main]
67+
steps:
68+
- run: apt-get update
69+
- run: apt-get upgrade -y
70+
- run: |
71+
apt-get install -y \
72+
ca-certificates \
73+
build-essential \
74+
file \
75+
gcc-aarch64-linux-gnu \
76+
libarchive-tools \
77+
makepkg \
78+
pacman-package-manager \
79+
rclone \
80+
tree \
81+
unzip
82+
- uses: crazy-max/ghaction-import-gpg@v7
83+
with:
84+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
85+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
86+
- uses: actions/checkout@v6
87+
- uses: actions/setup-go@v6
88+
with:
89+
cache: true
90+
go-version-file: go.mod
91+
- uses: sqlc-dev/setup-sqlc@v4
92+
with:
93+
sqlc-version: 1.30.0
94+
- run: sqlc generate
95+
- run: go install github.com/google/go-licenses/v2@latest
96+
- run: useradd -m builder
97+
- run: ./pkg/buildarch.bash
98+
- uses: actions/upload-artifact@v6
99+
with:
100+
name: arch
101+
path: |
102+
pkg/arch/*-aarch64.pkg.tar.zst
103+
pkg/arch/*-aarch64.pkg.tar.zst.sig
104+
pkg/arch/*-x86_64.pkg.tar.zst
105+
pkg/arch/*-x86_64.pkg.tar.zst.sig
106+
retention-days: 1

pkg/PKGBUILD

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
pkgname=modctl
2+
pkgver=PKGVER
3+
pkgrel=1
4+
pkgdesc="command line mod manager"
5+
arch=(aarch64 x86_64)
6+
url=https://modctl.org
7+
license=(GPL-3.0-or-later)
8+
depends=(glibc)
9+
source=(file://modctl
10+
file://modctl.bash
11+
file://modctl.fish
12+
file://modctl.zsh
13+
file://licenses.tar
14+
file://LICENSE)
15+
md5sums=(SKIP SKIP SKIP SKIP SKIP SKIP)
16+
17+
package() {
18+
install -Dm0755 "$srcdir/modctl" "$pkgdir/usr/bin/modctl"
19+
install -Dm0644 "$srcdir/LICENSE" "$pkgdir/usr/share/licenses/modctl/LICENSE"
20+
cp -r "$srcdir/licenses" "$pkgdir/usr/share/licenses/modctl/vendor"
21+
install -Dm0644 "$srcdir/modctl.bash" "$pkgdir/usr/share/bash-completions/completions/modctl"
22+
install -Dm0644 "$srcdir/modctl.fish" "$pkgdir/usr/share/fish/vendor_completions.d/modctl.fish"
23+
install -Dm0644 "$srcdir/modctl.zsh" "$pkgdir/usr/share/zsh/site-functions/_modctl"
24+
}

pkg/buildarch.bash

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
pkgver="$(grep -P "^\tVersion:" cmd/root.go | awk -F\" '{print $2}')"
4+
5+
mkdir pkg/arch
6+
sed -e "s/PKGVER/$pkgver/" pkg/PKGBUILD > pkg/arch/PKGBUILD
7+
go-licenses save ./... --ignore github.com/mfinelli/modctl --save_path \
8+
pkg/licenses
9+
find pkg/licenses -type f -exec chmod 0644 {} \;
10+
11+
(
12+
cd pkg || exit 1
13+
tar cvf arch/licenses.tar licenses
14+
)
15+
16+
make
17+
./modctl completion bash > pkg/arch/modctl.bash
18+
./modctl completion fish > pkg/arch/modctl.fish
19+
./modctl completion zsh > pkg/arch/modctl.zsh
20+
cp LICENSE pkg/arch
21+
mv modctl pkg/arch
22+
23+
(
24+
set -e
25+
chown -R builder:builder pkg/arch
26+
cd pkg/arch
27+
su builder -c "makepkg --nodeps"
28+
find . -name '*-x86_64.pkg.tar.zst' -exec \
29+
gpg --detach-sign \
30+
-u pkg@modctl.org \
31+
{} \;
32+
)
33+
34+
export CC=aarch64-linux-gnu-gcc
35+
export GOARCH=arm64
36+
make modctl
37+
mv modctl pkg/arch
38+
39+
(
40+
set -e
41+
cd pkg/arch
42+
su builder -c "CARCH=aarch64 makepkg --nodeps"
43+
find . -name '*-aarch64.pkg.tar.zst' -exec \
44+
gpg --detach-sign \
45+
-u pkg@modctl.org \
46+
{} \;
47+
)

pkg/publish.bash

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ done
2222

2323
echo "$RCLONE_CONFIG" > pkg/rclone.conf
2424

25-
echo "Pulling current repo state from R2..."
2625
WORKDIR="$(mktemp -d)"
2726
mkdir -p "$WORKDIR/repo"
28-
rclone sync --config pkg/rclone.conf r2:modctl-pkgs "$WORKDIR/repo"
27+
28+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
29+
echo "Pulling current repo state from R2..."
30+
rclone sync --config pkg/rclone.conf r2:modctl-pkgs "$WORKDIR/repo"
31+
fi
2932

3033
echo "Exporting public key..."
3134
gpg --armor --export pkg@modctl.org > "$WORKDIR/repo/pubkey.asc"
@@ -102,6 +105,9 @@ done
102105

103106
tree "$WORKDIR"
104107

105-
rclone sync --config pkg/rclone.conf "$WORKDIR/repo" r2:modctl-pkgs
108+
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
109+
echo "Pushing updated repo to R2..."
110+
rclone sync --config pkg/rclone.conf "$WORKDIR/repo" r2:modctl-pkgs
111+
fi
106112

107113
exit 0

0 commit comments

Comments
 (0)