Skip to content

Commit 2dbe0ab

Browse files
committed
maybe support arm on easy install.
1 parent 0d387a6 commit 2dbe0ab

4 files changed

Lines changed: 48 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
build-and-release:
13-
name: Build and release binary
12+
build:
13+
name: Build binaries and create release
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
@@ -19,6 +19,8 @@ jobs:
1919
go-version: '1.25'
2020
- name: Install musl and musl-gcc
2121
run: sudo apt-get update && sudo apt-get install -y musl-tools
22+
- name: Install ARM cross-compiler
23+
run: sudo apt-get install -y gcc-aarch64-linux-gnu
2224
- name: Get templ version
2325
run: echo "TEMPL_VERSION=$(grep 'github.com/a-h/templ' go.mod | awk '{print $2}')" >> $GITHUB_ENV
2426
- name: Install templ
@@ -30,9 +32,14 @@ jobs:
3032
- name: Install Nodejs dependencies (Tailwind)
3133
run: npm install
3234
- uses: extractions/setup-just@v2
33-
- name: Build binary
34-
run: just build
35+
- name: Build amd64 binary
36+
run: |
37+
just build
38+
mv pyramid-exe pyramid-amd64
39+
- name: Build arm64 binary
40+
run: |
41+
just build cc=aarch64-linux-gnu-gcc arch=arm64
3542
- name: Create release
3643
uses: softprops/action-gh-release@v2
3744
with:
38-
files: pyramid-exe
45+
files: pyramid-*

easy.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ ufw allow https
66

77
# download binary into ./pyramid directory
88
VERSION=$(curl -s "https://api.github.com/repos/fiatjaf/pyramid/releases/latest" | grep '"tag_name":' | cut -d '"' -f 4)
9+
case $(uname -m) in
10+
x86_64)
11+
ARCH="amd64"
12+
;;
13+
aarch64)
14+
ARCH="arm64"
15+
;;
16+
*)
17+
echo "unsupported architecture: $(uname -m)"
18+
exit 1
19+
;;
20+
esac
921
mkdir -p pyramid
1022
cd pyramid
11-
rm pyramid-exe-old
12-
mv pyramid-exe pyramid-exe-old
13-
wget "https://github.com/fiatjaf/pyramid/releases/download/$VERSION/pyramid-exe"
14-
chmod +x pyramid-exe
23+
rm pyramid-old
24+
mv pyramid pyramid-old 2>/dev/null || true
25+
wget "https://github.com/fiatjaf/pyramid/releases/download/$VERSION/pyramid-$ARCH"
26+
mv "pyramid-$ARCH" pyramid
27+
chmod +x pyramid
1528
DIR=$(pwd)
1629

1730
# create systemd service file
@@ -21,9 +34,10 @@ After=network.target
2134
2235
[Service]
2336
User=$USER
24-
ExecStart=$DIR/pyramid-exe
37+
ExecStart=$DIR/pyramid
2538
WorkingDirectory=$DIR
2639
Restart=always
40+
RestartSec=60
2741
Environment=HOST=0.0.0.0 PORT=443
2842
2943
[Install]

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
dev:
22
fd 'go|templ' | entr -r bash -c 'just templ && just tailwind && go build -o ./pyramid-exe && godotenv ./pyramid-exe'
33

4-
build: templ tailwind
4+
build cc='musl-gcc' arch='amd64': templ tailwind
55
#!/bin/bash
66

77
# set the global variable `currentVersion` to the latest git tag if we're in it, otherwise use the name of the latest tag + the first 8 characters of the current commit
88
VERSION=$(git describe --tags --exact-match 2>/dev/null || echo "$(git describe --tags --abbrev=0)-$(git rev-parse --short=8 HEAD)")
99

1010
# build with musl for maximum compatibility everywhere
11-
CC=musl-gcc go build -tags=libsecp256k1 -ldflags="-X main.currentVersion=$VERSION -linkmode external -extldflags \"-static\"" -o ./pyramid-exe
11+
CC={{cc}} CGO_ENABLED=1 GOARCH={{arch}} GOOS=linux go build -tags=libsecp256k1 -ldflags="-X main.currentVersion=$VERSION -linkmode external -extldflags \"-static\"" -o ./pyramid-exe
1212

1313
templ:
1414
templ generate

updates.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"os"
99
"path/filepath"
10+
"runtime"
1011
"syscall"
1112
"time"
1213

@@ -56,16 +57,27 @@ func fetchLatestVersion() {
5657
return
5758
}
5859

59-
// find the pyramid-exe asset
60+
// determine architecture and find the corresponding binary asset
6061
var binaryURL string
62+
var expectedBinaryName string
63+
switch runtime.GOARCH {
64+
case "amd64":
65+
expectedBinaryName = "pyramid-amd64"
66+
case "arm64":
67+
expectedBinaryName = "pyramid-arm64"
68+
default:
69+
log.Error().Str("arch", runtime.GOARCH).Msg("unsupported architecture")
70+
return
71+
}
72+
6173
for _, asset := range release.Assets {
62-
if asset.Name == "pyramid-exe" {
74+
if asset.Name == expectedBinaryName {
6375
binaryURL = asset.URL
6476
break
6577
}
6678
}
6779
if binaryURL == "" {
68-
log.Error().Msg("pyramid-exe asset not found in latest release")
80+
log.Error().Str("binary", expectedBinaryName).Msg("binary asset not found in latest release")
6981
return
7082
}
7183

0 commit comments

Comments
 (0)