From bbf29104fea48820f2bba6626006668853e0b3f3 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Tue, 14 Mar 2023 23:30:44 +0100 Subject: [PATCH] Add release pipeline --- .github/workflows/go.yml | 24 ++++++++++-------------- .github/workflows/publish.yml | 21 +++++++++++++++++++++ Makefile | 23 +++++++++++------------ 3 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 45ae769..c3a7f2d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,17 +12,13 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: ^1.15 - - name: Check out code - uses: actions/checkout@v3 - - name: Build - run: make build - - name: Test - run: make test-with-coverage - # - uses: codecov/codecov-action@v1 - # with: - # token: ${{ secrets.CODECOV_TOKEN }} - # files: coverage.out + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ^1.15 + - name: Checkout + uses: actions/checkout@v3 + - name: Build + run: make build-all + - name: Test + run: make test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d4289db --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,21 @@ +name: Publish + +on: + push: + tags: + - "v*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build + run: make build-all + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: | + bin/edgeboxctl-linux-amd64 + bin/edgeboxctl-linux-arm diff --git a/Makefile b/Makefile index f8be198..2649ac2 100644 --- a/Makefile +++ b/Makefile @@ -6,14 +6,14 @@ BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S') BUILD_DIR = bin build-all: - GOOS=linux GOARCH=amd64 make build + make build-arm + make build-amd64 + +build-arm: GOOS=linux GOARCH=arm make build -build-prod: - GOOS=linux GOARCH=arm RELEASE=prod make build - -build-cloud: - GOOS=linux GOARCH=amd64 RELEASE=cloud make build +build-amd64: + GOOS=linux GOARCH=amd64 make build build: @echo "Building ${GOOS}-${GOARCH}" @@ -22,7 +22,6 @@ build: -X ${PROJECT}/internal/diagnostics.Commit=${COMMIT} \ -X ${PROJECT}/internal/diagnostics.BuildDate=${BUILD_DATE}" \ -o bin/edgeboxctl-${GOOS}-${GOARCH} ${PROJECT}/cmd/edgeboxctl - cp ./bin/edgeboxctl-${GOOS}-${GOARCH} ./bin/edgeboxctl clean: rm -rf ${BUILD_DIR} @@ -34,16 +33,16 @@ test: test-with-coverage: go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out -install-cloud: build-cloud - cp ./bin/edgeboxctl /usr/local/bin/edgeboxctl +install-cloud: build-amd64 + cp ./bin/edgeboxctl-amd64 /usr/local/bin/edgeboxctl cp ./edgeboxctl/edgeboxctl.service /lib/systemd/system/edgeboxctl.service systemctl daemon-reload @echo "Edgeboxctl installed successfully" @echo "To start edgeboxctl run: systemctl start edgeboxctl" -install-prod: build-prod - cp ./bin/edgeboxctl /usr/local/bin/edgeboxctl +install-prod: build-arm + cp ./bin/edgeboxctl-arm /usr/local/bin/edgeboxctl cp ./edgeboxctl/edgeboxctl.service /lib/systemd/system/edgeboxctl.service systemctl daemon-reload @echo "Edgeboxctl installed successfully" - @echo "To start edgeboxctl run: systemctl start edgeboxctl" \ No newline at end of file + @echo "To start edgeboxctl run: systemctl start edgeboxctl"