diff --git a/.github/workflows/build-deb.sh b/.github/workflows/build-deb.sh index 6baa68e12..577ffb26e 100755 --- a/.github/workflows/build-deb.sh +++ b/.github/workflows/build-deb.sh @@ -6,8 +6,8 @@ sudo apt-get update sudo apt-get install -y make # We set this here, so it's the same between the copydb and sharding debian -# package. -DATETIME=$(date -u +%Y%m%d%H%M%S) +# package, and between different arch builds +DATETIME=$(date -u +%Y%m%d) git status @@ -15,16 +15,11 @@ make copydb-deb DATETIME=${DATETIME} make sharding-deb DATETIME=${DATETIME} cd build -sha256sum *.deb > ghostferry-$GITHUB_SHA.sha256sum - set +x echo "Debian package built successfully as follows:" ls -l ghostferry* -echo "sha256sum:" -cat ghostferry-$GITHUB_SHA.sha256sum - # Make sure the we didn't release a dirty build by accident if ls | grep -q dirty; then echo "ERROR: source directory is not clean! refused to release. showing git status below:" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac1ae5734..df63c2a3e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -71,4 +71,44 @@ jobs: - name: Running Ruby tests run: bundle exec ruby test/main.rb + build-debs: + strategy: + matrix: + runner: [ubuntu-latest, shopify-ubuntu-arm64] + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v2 + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Building Ghostferry + run: .github/workflows/build-deb.sh + + - name: Upload debs + uses: actions/upload-artifact@v3 + with: + name: debs-${{ github.sha }} + path: build/ghostferry* + + checksum-debs: + runs-on: ubuntu-latest + needs: build-debs + steps: + - name: Fetch uploaded artifacts + uses: actions/download-artifact@v3 + with: + name: debs-${{ github.sha }} + - name: shasum + shell: bash + run: | + sha256sum *.deb > ghostferry-$GITHUB_SHA.sha256sum + echo "sha256sum:" + cat ghostferry-$GITHUB_SHA.sha256sum + - name: Upload checksum + uses: actions/upload-artifact@v3 + with: + name: debs-${{ github.sha }} + path: "*.sha256sum" diff --git a/Makefile b/Makefile index 29416f0d9..3c88a1ef0 100644 --- a/Makefile +++ b/Makefile @@ -26,15 +26,15 @@ BIN_DIR := usr/bin PROJECTS := copydb sharding PROJECT_DEBS := $(foreach name,$(PROJECTS),$(name)-deb) +PLATFORM := $(shell uname -s | tr A-Z a-z) +ARCH := $(shell uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g') +GOTESTSUM_URL := "https://github.com/gotestyourself/gotestsum/releases/download/v1.7.0/gotestsum_1.7.0_$(PLATFORM)_$(ARCH).tar.gz" + # Target specific variable, set proj to have a valid value. PROJECT_PKG = ./$(proj)/cmd PROJECT_BIN = ghostferry-$(proj) BIN_TARGET = $(GOBIN)/$(PROJECT_BIN) -DEB_TARGET = $(BUILD_DIR)/$(PROJECT_BIN)_$(VERSION_STR).deb - -PLATFORM := $(shell uname -s | tr A-Z a-z) -ARCH := $(shell uname -m | sed 's/x86_64/amd64/g' | sed 's/aarch64/arm64/g') -GOTESTSUM_URL := "https://github.com/gotestyourself/gotestsum/releases/download/v1.7.0/gotestsum_1.7.0_$(PLATFORM)_$(ARCH).tar.gz" +DEB_TARGET = $(BUILD_DIR)/$(PROJECT_BIN)_$(VERSION_STR)_$(ARCH).deb .PHONY: test test-go test-ruby clean reset-deb-dir $(PROJECTS) $(PROJECT_DEBS) .DEFAULT_GOAL := test @@ -46,7 +46,7 @@ $(PROJECTS): $(GOBIN) $(PROJECT_DEBS): LDFLAGS += -X github.com/Shopify/ghostferry.WebUiBasedir=/$(SHARE_DIR) $(PROJECT_DEBS): reset-deb-dir $(eval proj := $(subst -deb,,$@)) - sed -e "s/{version}/$(VERSION_STR)/" $(proj)/debian/control > $(DEB_PREFIX)/DEBIAN/control + sed -e "s/{version}/$(VERSION_STR)/" -e "s/{arch}/$(ARCH)/" $(proj)/debian/control > $(DEB_PREFIX)/DEBIAN/control cp $(proj)/debian/copyright $(DEB_PREFIX)/DEBIAN/copyright go build -ldflags "$(LDFLAGS)" -o $(DEB_PREFIX)/$(BIN_DIR)/$(PROJECT_BIN) $(PROJECT_PKG) cp -ar webui $(DEB_PREFIX)/$(SHARE_DIR) diff --git a/copydb/debian/control b/copydb/debian/control index 564853126..300d9c1bf 100644 --- a/copydb/debian/control +++ b/copydb/debian/control @@ -2,7 +2,7 @@ Package: ghostferry-copydb Version: {version}-1 Section: misc Priority: optional -Architecture: amd64 +Architecture: {arch} Maintainer: Shuhao Wu Description: Migrate MySQL data from one server to another without downtime via ghostferry. diff --git a/sharding/debian/control b/sharding/debian/control index 972a5e233..f37106e11 100644 --- a/sharding/debian/control +++ b/sharding/debian/control @@ -2,7 +2,7 @@ Package: ghostferry-sharding Version: {version} Section: misc Priority: optional -Architecture: amd64 +Architecture: {arch} Maintainer: Shuhao Wu Uploaders: Justin Li ,Hormoz Kheradmand Description: Migrate MySQL sharded data from one server to