Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: release names #150

Merged
merged 5 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: ci

on:
push:
Expand Down Expand Up @@ -52,6 +52,7 @@ jobs:
else
echo "✅ The documentation is up to date."
fi

test:
name: Test
runs-on: ubuntu-latest
Expand Down
39 changes: 18 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: polycli-releaser
name: release

on:
push:
Expand All @@ -8,8 +8,6 @@ on:

permissions:
contents: write
# packages: write
# issues: write

env:
GO_VERSION: "1.21"
Expand All @@ -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
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down