File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ permissions:
99 contents : write
1010
1111jobs :
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
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
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-*
Original file line number Diff line number Diff line change @@ -6,12 +6,25 @@ ufw allow https
66
77# download binary into ./pyramid directory
88VERSION=$( 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
921mkdir -p pyramid
1022cd 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
1528DIR=$( pwd)
1629
1730# create systemd service file
@@ -21,9 +34,10 @@ After=network.target
2134
2235[Service]
2336User=$USER
24- ExecStart=$DIR /pyramid-exe
37+ ExecStart=$DIR /pyramid
2538WorkingDirectory=$DIR
2639Restart=always
40+ RestartSec=60
2741Environment=HOST=0.0.0.0 PORT=443
2842
2943[Install]
Original file line number Diff line number Diff line change 11dev :
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=libsecp256 k1 -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=libsecp256 k1 -ldflags=" -X main.currentVersion=$VERSION -linkmode external -extldflags \" -static\" " -o ./ pyramid-exe
1212
1313templ :
1414 templ generate
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments