From 32176c74a096519dac942792acc7906c0cec5bc1 Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Wed, 29 Jan 2025 22:25:33 -0500 Subject: [PATCH 1/4] add cicd --- .github/workflows/cicd.yml | 49 ++++++++++++++++++++++++++++++++++++++ Makefile | 14 ++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..8d223d0 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,49 @@ +name: CI/CD Pipeline + +on: + push: + tags: + - "*" + +jobs: + release: + name: Build and Release + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Extract tag name + id: get-tag + run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: 1.23.1 + + - name: Build and push Docker images + run: | + TAG=${{ env.TAG }} + make docker-build-release tag=$TAG + + - name: Build binaries + run: | + make go-build-release + + - name: Upload artifacts from /bin + uses: actions/upload-artifact@v3 + with: + name: binaries + path: bin/ + diff --git a/Makefile b/Makefile index 378db1c..dadb9b3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,14 @@ all: build push +docker-build-release: + @if [ -z "$(tag)" ]; then \ + echo "Error: tag is required. Usage: make build-all tag="; \ + exit 1; \ + fi + docker buildx build --platform linux/arm64,linux/amd64 -t fosrl/gerbil:latest -f Dockerfile --push . + docker buildx build --platform linux/arm64,linux/amd64 -t fosrl/gerbil:$(tag) -f Dockerfile --push . + build: docker build -t fosrl/gerbil:latest . @@ -13,5 +21,9 @@ test: local: CGO_ENABLED=0 GOOS=linux go build -o gerbil +go-build-release: + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/gerbil_linux_arm64 + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/gerbil_linux_amd64 + clean: - rm gerbil \ No newline at end of file + rm gerbil From 6565fdbe62cc4561618f1452f7f6f9ba05bbd633 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 3 Mar 2025 22:36:58 -0500 Subject: [PATCH 2/4] Fix merge issue --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index a1d6aeb..dadb9b3 100644 --- a/Makefile +++ b/Makefile @@ -21,11 +21,7 @@ test: local: CGO_ENABLED=0 GOOS=linux go build -o gerbil -<<<<<<< HEAD go-build-release: -======= -release: ->>>>>>> bab8630756f5b243feec8a9e8952086498808a11 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/gerbil_linux_arm64 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/gerbil_linux_amd64 From 88be6d133dbaafd117a1cf33ec29bf91e8d4ebee Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 3 Mar 2025 22:38:49 -0500 Subject: [PATCH 3/4] Update upload action to v4 --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 8d223d0..93bae73 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -42,7 +42,7 @@ jobs: make go-build-release - name: Upload artifacts from /bin - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: binaries path: bin/ From cba4dc646d998e607ee6eb60227b800565250b93 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 3 Mar 2025 23:58:55 -0500 Subject: [PATCH 4/4] Try to setup qemu --- .github/workflows/cicd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 93bae73..d75f47f 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -14,6 +14,9 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2