diff --git a/.github/workflows/test.yml b/.github/workflows/ci.yml similarity index 99% rename from .github/workflows/test.yml rename to .github/workflows/ci.yml index 81310298..3c7aba86 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: ci on: push: @@ -52,6 +52,7 @@ jobs: else echo "✅ The documentation is up to date." fi + test: name: Test runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3635f03..c4543653 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: polycli-releaser +name: release on: push: @@ -8,8 +8,6 @@ on: permissions: contents: write - # packages: write - # issues: write env: GO_VERSION: "1.21" @@ -18,36 +16,35 @@ jobs: manual-release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Install go + uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} - name: Install packages run: sudo apt-get update && sudo apt-get install --yes gcc-aarch64-linux-gnu - - name: Perform cross build and compress binaries - shell: bash - run: | - make cross - pushd out - echo -n "${{github.ref_name}}" | sed 's/^v//' | tee ref_name.txt - readonly tag_name="$(cat ref_name.txt)" - echo "$tag_name" + - name: Perform cross builds + run: make cross - mkdir polycli_${tag_name}_linux_arm64/ - mv linux-arm64-polycli polycli_${tag_name}_linux_arm64/polycli - tar czf polycli_${tag_name}_linux_arm64.tar.gz polycli_${tag_name}_linux_arm64/ + - name: Compress binaries + run: | + cd out + tar czf polycli_${GITHUB_REF#refs/tags/}_linux_arm64.tar.gz polycli_${GITHUB_REF#refs/tags/}_linux_arm64/ + tar czf polycli_${GITHUB_REF#refs/tags/}_linux_amd64.tar.gz polycli_${GITHUB_REF#refs/tags/}_linux_amd64/ - mkdir polycli_${tag_name}_linux_amd64/ - mv linux-amd64-polycli polycli_${tag_name}_linux_amd64/polycli - tar czf polycli_${tag_name}_linux_amd64.tar.gz polycli_${tag_name}_linux_amd64/ + - name: Get git tag + run: echo "tag=$(git describe --tags --exact-match HEAD)" >> $GITHUB_ENV - name: Publish binaries uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ env.tag }} + release_name: ${{ env.tag }} + file_glob: true file: out/*.tar.gz - tag: ${{ github.ref }} overwrite: true - file_glob: true diff --git a/Makefile b/Makefile index 228bd683..87c51f9f 100644 --- a/Makefile +++ b/Makefile @@ -44,26 +44,26 @@ cross: $(BUILD_DIR) ## Cross-compile go binaries using CGO. # Notes: # - `-s -w` enables to strip debug and suppress warnings. # - `-linkmode external -extldflags "-static-libgo"` allows dynamic linking. - echo "Building linux-arm64-$(BIN_NAME)..." + echo "Building $(BIN_NAME)_$(GIT_TAG)_linux_arm64..." CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build \ -ldflags '$(VERSION_FLAGS) -s -w -linkmode external -extldflags "-static-libgo"' \ -tags netgo \ - -o $(BUILD_DIR)/linux-arm64-$(BIN_NAME) \ + -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_linux_arm64 \ main.go - echo "Building linux-amd64-$(BIN_NAME)..." + echo "Building $(BIN_NAME)_$(GIT_TAG)_linux_amd64..." CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \ -ldflags '$(VERSION_FLAGS) -s -w -linkmode external -extldflags "-static-libgo"' \ -tags netgo \ - -o $(BUILD_DIR)/linux-amd64-$(BIN_NAME) \ + -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_linux_amd64 \ main.go .PHONY: simplecross simplecross: $(BUILD_DIR) ## Cross-compile go binaries without using CGO. - GOOS=linux GOARCH=arm64 go build -o $(BUILD_DIR)/linux-arm64-$(BIN_NAME) main.go - GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/darwin-arm64-$(BIN_NAME) main.go - GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/linux-amd64-$(BIN_NAME) main.go - GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/darwin-amd64-$(BIN_NAME) main.go + GOOS=linux GOARCH=arm64 go build -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_linux_arm64 main.go + GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_darwin_arm64 main.go + GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_linux_amd64 main.go + GOOS=darwin GOARCH=amd64 go build -o $(BUILD_DIR)/$(BIN_NAME)_$(GIT_TAG)_darwin_amd64 main.go .PHONY: clean clean: ## Clean the binary folder.