Skip to content

Commit 6247257

Browse files
authored
Merge pull request #423 from Shopify/versioned-commands-for-testing
Versioned binaries as debs for testing
2 parents 4bc2247 + 59df8b9 commit 6247257

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

.github/workflows/build-deb.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ sudo apt-get install -y make
88
# We set this here, so it's the same between the copydb and sharding debian
99
# package, and between different arch builds
1010
DATETIME=$(date -u +%Y%m%d)
11+
COMMIT_SHA=$(git rev-parse --short HEAD)
12+
PROJECT_BIN_TAG="-$COMMIT_SHA"
1113

1214
git status
1315

14-
make copydb-deb DATETIME=${DATETIME}
15-
make sharding-deb DATETIME=${DATETIME}
16+
if [[ "$1" != "--tagged-only" ]] ; then
17+
make copydb-deb DATETIME=$DATETIME COMMIT_SHA=$COMMIT_SHA
18+
make sharding-deb DATETIME=$DATETIME COMMIT_SHA=$COMMIT_SHA
19+
fi
20+
21+
make copydb-deb DATETIME=$DATETIME COMMIT_SHA=$COMMIT_SHA PROJECT_BIN_TAG=$PROJECT_BIN_TAG
22+
make sharding-deb DATETIME=$DATETIME COMMIT_SHA=$COMMIT_SHA PROJECT_BIN_TAG=$PROJECT_BIN_TAG
1623

1724
cd build
1825
set +x

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
go-version: 1.24.1
100100

101101
- name: Building Ghostferry
102-
run: .github/workflows/build-deb.sh
102+
run: .github/workflows/build-deb.sh --tagged-only
103103

104104
- name: Upload debs
105105
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ ifndef IGNORE_DIRTY_TREE
88
DIRTY_TREE := $(shell git diff-index --quiet HEAD -- || echo '+dirty')
99
endif
1010

11-
COMMIT := $(addsuffix $(DIRTY_TREE),$(shell git rev-parse --short HEAD))
11+
COMMIT_SHA ?= $(shell git rev-parse --short HEAD)
12+
COMMIT := $(addsuffix $(DIRTY_TREE),$(COMMIT_SHA))
1213
VERSION_STR := $(VERSION)+$(DATETIME)+$(COMMIT)
1314

1415
# Flags
@@ -19,7 +20,7 @@ FIRSTGOPATH := $(firstword $(subst :, ,$(GOPATH)))
1920
GOBIN := $(FIRSTGOPATH)/bin
2021
BUILD_DIR := build
2122
DEB_PREFIX := $(BUILD_DIR)/debian
22-
SHARE_DIR := usr/share/ghostferry
23+
SHARE_DIR := usr/share/ghostferry$(PROJECT_BIN_TAG)
2324
BIN_DIR := usr/bin
2425

2526
# Targets
@@ -32,7 +33,7 @@ GOTESTSUM_URL := "https://github.com/gotestyourself/gotestsum/releases/downloa
3233

3334
# Target specific variable, set proj to have a valid value.
3435
PROJECT_PKG = ./$(proj)/cmd
35-
PROJECT_BIN = ghostferry-$(proj)
36+
PROJECT_BIN = ghostferry-$(proj)$(PROJECT_BIN_TAG)
3637
BIN_TARGET = $(GOBIN)/$(PROJECT_BIN)
3738
DEB_TARGET = $(BUILD_DIR)/$(PROJECT_BIN)_$(VERSION_STR)_$(ARCH).deb
3839

@@ -46,7 +47,7 @@ $(PROJECTS): $(GOBIN)
4647
$(PROJECT_DEBS): LDFLAGS += -X github.com/Shopify/ghostferry.WebUiBasedir=/$(SHARE_DIR)
4748
$(PROJECT_DEBS): reset-deb-dir
4849
$(eval proj := $(subst -deb,,$@))
49-
sed -e "s/{version}/$(VERSION_STR)/" -e "s/{arch}/$(ARCH)/" $(proj)/debian/control > $(DEB_PREFIX)/DEBIAN/control
50+
sed -e "s/{version}/$(VERSION_STR)/" -e "s/{arch}/$(ARCH)/" -e "s/{project}/$(PROJECT_BIN)/" $(proj)/debian/control > $(DEB_PREFIX)/DEBIAN/control
5051
cp $(proj)/debian/copyright $(DEB_PREFIX)/DEBIAN/copyright
5152
go build -ldflags "$(LDFLAGS)" -o $(DEB_PREFIX)/$(BIN_DIR)/$(PROJECT_BIN) $(PROJECT_PKG)
5253
cp -ar webui $(DEB_PREFIX)/$(SHARE_DIR)

copydb/debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Package: ghostferry-copydb
1+
Package: {project}
22
Version: {version}-1
33
Section: misc
44
Priority: optional

sharding/debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Package: ghostferry-sharding
1+
Package: {project}
22
Version: {version}
33
Section: misc
44
Priority: optional

sharding/debian/files/usr/bin/ghostferry-reloc

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)