detached d8476f6

refactor: Replace build-dev.sh and buildpush-dev.sh with unified Makefile

commit
d8476f660d8a1fc4b0433dc25c430b60cd481ed5
author
bamen · · 2024-10-15 17:23 UTC
committer
bamen · · 2024-10-15 20:08 UTC
parent
0472d4b
signature
unsigned
3 files · +55 -102
M Makefile +55 -11
@@ -1,19 +1,63 @@
11 # Variables
2-INSTALL_DIR = /usr/bin
3-BINARY_NAME = gordon
2+REPO := ghcr.io/bnema/gordon
3+TAG := dev
4+DIST_DIR := ./dist
5+ENGINE := podman
6+
7+# Architectures
8+ARCHS := amd64 arm64
9+
10+# Phony targets
11+.PHONY: all build build-push clean
12+
413 # Default target
514 all: build
615
7-# Build the Go binary
16+# Build binaries
817 build:
9- go build -o $(BINARY_NAME) cmd/cli/main.go
18+ @echo "Building Go binaries..."
19+ @mkdir -p $(DIST_DIR)
20+ @rm -f $(DIST_DIR)/*
21+ @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(DIST_DIR)/gordon-linux-amd64 ./main.go
22+ @CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(DIST_DIR)/gordon-linux-arm64 ./main.go
23+ @echo "Go binaries built successfully"
1024
11-# Install the binary to /usr/local/bin
12-install:
13- mv $(BINARY_NAME) $(INSTALL_DIR)
25+# Build and push Docker images
26+build-push: build
27+ @echo "Cleaning up dangling images..."
28+ @$(ENGINE) image prune -f
1429
15-# Clean up the built binary
16-clean:
17- rm -f $(BINARY_NAME)
30+ @echo "Building and pushing Docker images..."
31+ @for arch in $(ARCHS); do \
32+ cp $(DIST_DIR)/gordon-linux-$$arch gordon; \
33+ $(ENGINE) build -t $(REPO):$(TAG)-$$arch .; \
34+ rm gordon; \
35+ $(ENGINE) push $(REPO):$(TAG)-$$arch; \
36+ done
37+
38+ @echo "Removing existing manifest..."
39+ @$(ENGINE) manifest rm $(REPO):$(TAG) || true
40+
41+ @echo "Creating multi-arch manifest..."
42+ @$(ENGINE) manifest create $(REPO):$(TAG) \
43+ $(REPO):$(TAG)-amd64 \
44+ $(REPO):$(TAG)-arm64
1845
19-.PHONY: all build install clean⏎̸
46+ @echo "Annotating arm64 image..."
47+ @$(ENGINE) manifest annotate $(REPO):$(TAG) \
48+ $(REPO):$(TAG)-arm64 --arch arm64 --variant v8
49+
50+ @echo "Inspecting manifest..."
51+ @$(ENGINE) manifest inspect $(REPO):$(TAG)
52+
53+ @echo "Pushing multi-arch manifest..."
54+ @$(ENGINE) manifest push --all $(REPO):$(TAG)
55+
56+ @echo "Script completed successfully."
57+
58+# Clean up
59+clean:
60+ @echo "Cleaning up..."
61+ @rm -rf $(DIST_DIR)
62+ @$(ENGINE) system prune -f
63+ @echo "Cleanup completed."⏎̸
@@ -1,19 +1,63 @@
1 # Variables1 # Variables
2-INSTALL_DIR = /usr/bin2+REPO := ghcr.io/bnema/gordon
3-BINARY_NAME = gordon 3+TAG := dev
4+DIST_DIR := ./dist
5+ENGINE := podman
6+
7+# Architectures
8+ARCHS := amd64 arm64
9+
10+# Phony targets
11+.PHONY: all build build-push clean
12+
4 # Default target13 # Default target
5 all: build14 all: build
6 15
7-# Build the Go binary16+# Build binaries
8 build:17 build:
9- go build -o $(BINARY_NAME) cmd/cli/main.go18+ @echo "Building Go binaries..."
19+ @mkdir -p $(DIST_DIR)
20+ @rm -f $(DIST_DIR)/*
21+ @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(DIST_DIR)/gordon-linux-amd64 ./main.go
22+ @CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $(DIST_DIR)/gordon-linux-arm64 ./main.go
23+ @echo "Go binaries built successfully"
10 24
11-# Install the binary to /usr/local/bin25+# Build and push Docker images
12-install:26+build-push: build
13- mv $(BINARY_NAME) $(INSTALL_DIR)27+ @echo "Cleaning up dangling images..."
28+ @$(ENGINE) image prune -f
14 29
15-# Clean up the built binary30+ @echo "Building and pushing Docker images..."
16-clean:31+ @for arch in $(ARCHS); do \
17- rm -f $(BINARY_NAME)32+ cp $(DIST_DIR)/gordon-linux-$$arch gordon; \
33+ $(ENGINE) build -t $(REPO):$(TAG)-$$arch .; \
34+ rm gordon; \
35+ $(ENGINE) push $(REPO):$(TAG)-$$arch; \
36+ done
37+
38+ @echo "Removing existing manifest..."
39+ @$(ENGINE) manifest rm $(REPO):$(TAG) || true
40+
41+ @echo "Creating multi-arch manifest..."
42+ @$(ENGINE) manifest create $(REPO):$(TAG) \
43+ $(REPO):$(TAG)-amd64 \
44+ $(REPO):$(TAG)-arm64
18 45
19-.PHONY: all build install clean⏎̸46+ @echo "Annotating arm64 image..."
47+ @$(ENGINE) manifest annotate $(REPO):$(TAG) \
48+ $(REPO):$(TAG)-arm64 --arch arm64 --variant v8
49+
50+ @echo "Inspecting manifest..."
51+ @$(ENGINE) manifest inspect $(REPO):$(TAG)
52+
53+ @echo "Pushing multi-arch manifest..."
54+ @$(ENGINE) manifest push --all $(REPO):$(TAG)
55+
56+ @echo "Script completed successfully."
57+
58+# Clean up
59+clean:
60+ @echo "Cleaning up..."
61+ @rm -rf $(DIST_DIR)
62+ @$(ENGINE) system prune -f
63+ @echo "Cleanup completed."⏎̸
D build-dev.sh +0 -20
@@ -1,20 +0,0 @@
1-#!/bin/bash
2-
3-set -e
4-
5-REPO="ghcr.io/bnema/gordon"
6-TAG="dev"
7-DIST_DIR="./dist"
8-
9-# Ensure dist directory exists
10-mkdir -p $DIST_DIR
11-
12-# Clean up previous builds
13-rm -f $DIST_DIR/*
14-
15-# Build Go binaries for multiple platforms with CGO_ENABLED=0
16-echo "Building Go binaries..."
17-CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./main.go
18-CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./main.go
19-
20-echo "Successfully built Go binaries"
@@ -1,20 +0,0 @@
1-#!/bin/bash
2-
3-set -e
4-
5-REPO="ghcr.io/bnema/gordon"
6-TAG="dev"
7-DIST_DIR="./dist"
8-
9-# Ensure dist directory exists
10-mkdir -p $DIST_DIR
11-
12-# Clean up previous builds
13-rm -f $DIST_DIR/*
14-
15-# Build Go binaries for multiple platforms with CGO_ENABLED=0
16-echo "Building Go binaries..."
17-CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./main.go
18-CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./main.go
19-
20-echo "Successfully built Go binaries"
D buildpush-dev.sh +0 -71
@@ -1,71 +0,0 @@
1-#!/bin/bash
2-set -e
3-ENGINE="podman"
4-REPO="ghcr.io/bnema/gordon"
5-TAG="dev"
6-DIST_DIR="./dist"
7-
8-# Function to handle errors
9-handle_error() {
10- echo "Error occurred. Cleaning up..."
11- $ENGINE system prune -f
12- exit 1
13-}
14-
15-# Set up error handling
16-trap 'handle_error' ERR
17-
18-# Ensure dist directory exists
19-mkdir -p $DIST_DIR
20-
21-# Build Go binaries for multiple platforms with CGO_ENABLED=0
22-echo "Building Go binaries..."
23-CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./main.go
24-CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./main.go
25-
26-# Clean up any dangling images before building
27-echo "Cleaning up dangling images..."
28-$ENGINE image prune -f
29-
30-# Build Docker images for each architecture
31-echo "Building Docker images..."
32-for ARCH in amd64 arm64; do
33- # Copy the appropriate binary to the root directory and rename it to 'gordon'
34- cp $DIST_DIR/gordon-linux-$ARCH gordon
35-
36- # Build the Docker image
37- $ENGINE build -t $REPO:${TAG}-$ARCH .
38-
39- # Remove the temporary 'gordon' file
40- rm gordon
41-done
42-
43-# Push images
44-echo "Pushing Docker images..."
45-$ENGINE push $REPO:${TAG}-amd64
46-$ENGINE push $REPO:${TAG}-arm64
47-
48-# Remove existing manifest if it exists
49-echo "Removing existing manifest..."
50-$ENGINE manifest rm $REPO:$TAG || true
51-
52-# Create multi-arch manifest
53-echo "Creating multi-arch manifest..."
54-$ENGINE manifest create $REPO:$TAG \
55- $REPO:${TAG}-amd64 \
56- $REPO:${TAG}-arm64
57-
58-# Annotate the arm64 image with variant information
59-echo "Annotating arm64 image..."
60-$ENGINE manifest annotate $REPO:$TAG \
61- $REPO:${TAG}-arm64 --arch arm64 --variant v8
62-
63-# Debug: List manifests
64-echo "Listing manifests..."
65-$ENGINE manifest inspect $REPO:$TAG
66-
67-# Push multi-arch manifest
68-echo "Pushing multi-arch manifest..."
69-$ENGINE manifest push --all $REPO:$TAG
70-
71-echo "Script completed successfully."
@@ -1,71 +0,0 @@
1-#!/bin/bash
2-set -e
3-ENGINE="podman"
4-REPO="ghcr.io/bnema/gordon"
5-TAG="dev"
6-DIST_DIR="./dist"
7-
8-# Function to handle errors
9-handle_error() {
10- echo "Error occurred. Cleaning up..."
11- $ENGINE system prune -f
12- exit 1
13-}
14-
15-# Set up error handling
16-trap 'handle_error' ERR
17-
18-# Ensure dist directory exists
19-mkdir -p $DIST_DIR
20-
21-# Build Go binaries for multiple platforms with CGO_ENABLED=0
22-echo "Building Go binaries..."
23-CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $DIST_DIR/gordon-linux-amd64 ./main.go
24-CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o $DIST_DIR/gordon-linux-arm64 ./main.go
25-
26-# Clean up any dangling images before building
27-echo "Cleaning up dangling images..."
28-$ENGINE image prune -f
29-
30-# Build Docker images for each architecture
31-echo "Building Docker images..."
32-for ARCH in amd64 arm64; do
33- # Copy the appropriate binary to the root directory and rename it to 'gordon'
34- cp $DIST_DIR/gordon-linux-$ARCH gordon
35-
36- # Build the Docker image
37- $ENGINE build -t $REPO:${TAG}-$ARCH .
38-
39- # Remove the temporary 'gordon' file
40- rm gordon
41-done
42-
43-# Push images
44-echo "Pushing Docker images..."
45-$ENGINE push $REPO:${TAG}-amd64
46-$ENGINE push $REPO:${TAG}-arm64
47-
48-# Remove existing manifest if it exists
49-echo "Removing existing manifest..."
50-$ENGINE manifest rm $REPO:$TAG || true
51-
52-# Create multi-arch manifest
53-echo "Creating multi-arch manifest..."
54-$ENGINE manifest create $REPO:$TAG \
55- $REPO:${TAG}-amd64 \
56- $REPO:${TAG}-arm64
57-
58-# Annotate the arm64 image with variant information
59-echo "Annotating arm64 image..."
60-$ENGINE manifest annotate $REPO:$TAG \
61- $REPO:${TAG}-arm64 --arch arm64 --variant v8
62-
63-# Debug: List manifests
64-echo "Listing manifests..."
65-$ENGINE manifest inspect $REPO:$TAG
66-
67-# Push multi-arch manifest
68-echo "Pushing multi-arch manifest..."
69-$ENGINE manifest push --all $REPO:$TAG
70-
71-echo "Script completed successfully."

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close