Skip to content

Commit c8c632a

Browse files
committed
Add riscv native build/release CI
1 parent b171682 commit c8c632a

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

.github/workflows/go.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, macos-13, windows-latest]
15+
include:
16+
- os: self-hosted # Add a native RISC-V leg that uses your self-hosted riscv64 runner
17+
runs_on: '["self-hosted","Linux","riscv64"]'
1518
runs-on: ${{ matrix.os }}
1619
environment: CI
1720
steps:
@@ -23,8 +26,16 @@ jobs:
2326
uses: actions/setup-go@v5
2427
with:
2528
go-version: "1.23"
29+
30+
- name: Install dependencies (for self-hosted only)
31+
if: matrix.os == 'self-hosted'
32+
shell: bash
33+
run: |
34+
sudo apt update
35+
sudo apt install -y make build-essential
2636
2737
- name: Unit Test
38+
if: matrix.os != 'self-hosted'
2839
run: make test
2940
- name: Upload coverage infomartion
3041
uses: codecov/codecov-action@v4

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,29 @@ jobs:
107107
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/v3/cli.Version=${VERSION}'" -o out/aliyun main/main.go
108108
tar zcvf out/aliyun-cli-linux-${VERSION}-arm64.tgz -C out aliyun
109109
bash tools/upload_asset.sh ${VERSION} out/aliyun-cli-linux-${VERSION}-arm64.tgz
110+
build_for_linux_riscv64:
111+
needs: [create_release]
112+
name: Native RISC-V Build
113+
runs-on: self-hosted
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
116+
steps:
117+
- uses: actions/checkout@v4
118+
with:
119+
submodules: true
120+
ref: ${{ github.ref }}
121+
- name: Set up Go
122+
uses: actions/setup-go@v5
123+
with:
124+
go-version: '1.23'
125+
- name: Build
126+
run: |
127+
TAG=${{ github.ref_name }}
128+
VERSION=${TAG#v}
129+
# build for Linux riscv64 (native)
130+
CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/v3/cli.Version=${VERSION}'" -o out/aliyun main/main.go
131+
tar zcvf out/aliyun-cli-linux-${VERSION}-riscv64.tgz -C out aliyun
132+
bash tools/upload_asset.sh ${VERSION} out/aliyun-cli-linux-${VERSION}-riscv64.tgz
110133
build_for_windows:
111134
needs: [create_release]
112135
name: Build for Windows

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export VERSION=3.0.0-beta
22
export RELEASE_PATH="releases/aliyun-cli-${VERSION}"
3+
ARCH ?= $(shell uname -m)
34

45
all: build
56
publish: build build_mac build_linux build_windows build_linux_arm64 gen_version
@@ -14,7 +15,12 @@ build: deps
1415
go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o out/aliyun main/main.go
1516

1617
install: build
17-
cp out/aliyun /usr/local/bin
18+
@if [ "$(ARCH)" = "riscv64" ]; then \
19+
install -d "$(HOME)/.local/bin"; \
20+
install -m755 out/aliyun "$(HOME)/.local/bin/aliyun"; \
21+
else \
22+
install -Dm755 out/aliyun /usr/local/bin/aliyun; \
23+
fi
1824

1925
build_mac:
2026
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o out/aliyun main/main.go

0 commit comments

Comments
 (0)