From 0668eaea1e55c20f59630a05539da813255ebd35 Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Tue, 4 Apr 2023 20:30:19 +0800 Subject: [PATCH] feat: add latest release of hgctl (#275) Signed-off-by: bitliu --- ...build-and-test.yml => build-and-test.yaml} | 0 ...deql-analysis.yml => codeql-analysis.yaml} | 0 .github/workflows/latest-release.yaml | 62 +++++++++++++++++++ Makefile.core.mk | 7 +++ 4 files changed, 69 insertions(+) rename .github/workflows/{build-and-test.yml => build-and-test.yaml} (100%) rename .github/workflows/{codeql-analysis.yml => codeql-analysis.yaml} (100%) create mode 100644 .github/workflows/latest-release.yaml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yaml similarity index 100% rename from .github/workflows/build-and-test.yml rename to .github/workflows/build-and-test.yaml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yaml similarity index 100% rename from .github/workflows/codeql-analysis.yml rename to .github/workflows/codeql-analysis.yaml diff --git a/.github/workflows/latest-release.yaml b/.github/workflows/latest-release.yaml new file mode 100644 index 000000000..39e2f6f10 --- /dev/null +++ b/.github/workflows/latest-release.yaml @@ -0,0 +1,62 @@ +name: Latest Release + +on: + push: + branches: + - "main" + +jobs: + latest-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build hgctl latest multiarch binaries + run: | + GOPROXY="https://proxy.golang.org,direct" make build-hgctl-multiarch + tar -zcvf hgctl_latest_linux_amd64.tar.gz out/linux_amd64/ + tar -zcvf hgctl_latest_linux_arm64.tar.gz out/linux_arm64/ + tar -zcvf hgctl_latest_darwin_amd64.tar.gz out/darwin_amd64/ + tar -zcvf hgctl_latest_darwin_arm64.tar.gz out/darwin_arm64/ + + # Ignore the error when we delete the latest release, it might not exist. + + # GitHub APIs take sometime to make effect, we should make sure before Recreate the Latest Release and Tag, + # tag and release all get deleted. So we sleep sometime after deleting tag and release to wait for it taking effect. + + - name: Delete the Latest Release + continue-on-error: true + run: | + gh release delete latest --repo $GITHUB_REPOSITORY + sleep 4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository_owner }}/${{ github.event.repository.name }} + + # Ignore the error when we delete the latest tag, it might not exist. + - name: Delete the Latest Tag + continue-on-error: true + run: | + gh api --method DELETE /repos/$GITHUB_REPOSITORY/git/refs/tags/latest + sleep 4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository_owner }}/${{ github.event.repository.name }} + + - name: Recreate the Latest Release and Tag + uses: softprops/action-gh-release@v1 + with: + draft: false + prerelease: true + tag_name: latest + files: | + hgctl_latest_linux_amd64.tar.gz + hgctl_latest_linux_arm64.tar.gz + hgctl_latest_darwin_amd64.tar.gz + hgctl_latest_darwin_arm64.tar.gz + body: | + This is the "latest" release of **Higress**, which contains the most recent commits from the main branch. + + This release **might not be stable**. + + It is only intended for developers wishing to try out the latest features in Higress, some of which may not be fully implemented. diff --git a/Makefile.core.mk b/Makefile.core.mk index cbb90f0b2..91d50b0c7 100644 --- a/Makefile.core.mk +++ b/Makefile.core.mk @@ -75,6 +75,13 @@ build-hgctl: $(OUT) build-linux-hgctl: $(OUT) GOPROXY=$(GOPROXY) GOOS=linux GOARCH=$(GOARCH_LOCAL) LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh $(OUT_LINUX)/ $(HGCTL_BINARIES) +.PHONY: build-hgctl-multiarch +build-hgctl-multiarch: $(OUT) + GOPROXY=$(GOPROXY) GOOS=linux GOARCH=amd64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/linux_amd64/ $(HGCTL_BINARIES) + GOPROXY=$(GOPROXY) GOOS=linux GOARCH=arm64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/linux_arm64/ $(HGCTL_BINARIES) + GOPROXY=$(GOPROXY) GOOS=darwin GOARCH=amd64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/darwin_amd64/ $(HGCTL_BINARIES) + GOPROXY=$(GOPROXY) GOOS=darwin GOARCH=arm64 LDFLAGS=$(RELEASE_LDFLAGS) tools/hack/gobuild.sh ./out/darwin_arm64/ $(HGCTL_BINARIES) + # Create targets for OUT_LINUX/binary # There are two use cases here: # * Building all docker images (generally in CI). In this case we want to build everything at once, so they share work