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,9 +9,13 @@ permissions:
99 contents : write
1010
1111jobs :
12- build-and-release :
13- name : Build and release binary
12+ build :
13+ name : Build binary
1414 runs-on : ubuntu-latest
15+ strategy :
16+ matrix :
17+ goos : [linux]
18+ goarch : [amd64, arm64]
1519 steps :
1620 - uses : actions/checkout@v4
1721 - uses : actions/setup-go@v4
3135 run : npm install
3236 - uses : extractions/setup-just@v2
3337 - name : Build binary
34- run : just build
38+ env :
39+ GOOS : ${{ matrix.goos }}
40+ GOARCH : ${{ matrix.goarch }}
41+ run : |
42+ just build
43+ mv pyramid-exe pyramid-${{ matrix.goarch }}
44+ - name : Upload artifact
45+ uses : actions/upload-artifact@v4
46+ with :
47+ name : pyramid-${{ matrix.goarch }}
48+ path : pyramid-${{ matrix.goarch }}
49+ retention-days : 1
50+
51+ release :
52+ name : Create release
53+ needs : build
54+ runs-on : ubuntu-latest
55+ steps :
56+ - name : Download artifacts
57+ uses : actions/download-artifact@v4
58+ with :
59+ pattern : pyramid-*
60+ merge-multiple : true
3561 - name : Create release
3662 uses : softprops/action-gh-release@v2
3763 with :
38- files : pyramid-exe
64+ 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 @@ -8,7 +8,7 @@ build: templ tailwind
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=musl-gcc CGO_ENABLED= 1 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