ci(build): add amd64 build workflow and fix release conflicts

Add build-amd64.yml workflow mirroring build-arm64.yml for x86_64
Debian builds. Both workflows now use create-or-upload pattern
(gh release create || gh release upload --clobber) to prevent
tag conflicts when running concurrently.

Fix install_picoclaw.sh detect_arch() to return "x86_64" instead
of "amd64" to match GoReleaser archive naming convention.
This commit is contained in:
muava12 2026-02-25 09:07:25 +08:00
parent 4571031c0b
commit 5da0c87d19
3 changed files with 153 additions and 18 deletions

111
.github/workflows/build-amd64.yml vendored Normal file
View file

@ -0,0 +1,111 @@
name: Build Linux AMD64 (GoReleaser)
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-amd64:
name: Build Linux AMD64
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: 📢 Notify Start
run: |
curl \
-H "Title: Deploy picoclaw Linux AMD64 Started 🚀" \
-H "Tags: rocket,construction_worker" \
-H "Priority: default" \
-d "Branch: ${{ github.ref_name }} | Commit: ${{ github.sha }}" \
https://ntfy.sh/deploy-on-github-xasr6KBz47PjswPf53A78Fib
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
id: setup-go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Determine Fork Version
id: version
run: |
# Dapatkan tag terbaru dari history (mungkin sudah ada akhiran -fork)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
# Hilangkan akhiran -fork-* agar kita mendapatkan base version aslinya (misal: v0.1.2)
BASE_TAG=$(echo "$LATEST_TAG" | sed -E 's/-fork-[0-9]+//g')
# Format increment number menggunakan run number (misal: 01, 02)
RUN_NUM=$(printf "%02d" ${{ github.run_number }})
# Gabungkan menjadi versi custom untuk fork
FORK_VERSION="${BASE_TAG}-fork-${RUN_NUM}"
echo "Ditemukan tag asli: $BASE_TAG"
echo "Versi fork yang digunakan: $FORK_VERSION"
echo "FORK_VERSION=$FORK_VERSION" >> $GITHUB_ENV
- name: Restrict GoReleaser to linux/amd64
run: |
yq -i '.project_name = "picoclaw"' .goreleaser.yaml
yq -i '.builds[0].goos = ["linux"]' .goreleaser.yaml
yq -i '.builds[0].goarch = ["amd64"]' .goreleaser.yaml
yq -i 'del(.builds[0].ignore)' .goreleaser.yaml
yq -i 'del(.dockers_v2)' .goreleaser.yaml
yq -i '.snapshot.version_template = "{{ .Env.GORELEASER_CURRENT_TAG }}"' .goreleaser.yaml
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: ~> v2
args: release --clean --snapshot
env:
GOVERSION: ${{ steps.setup-go.outputs.go-version }}
# Override GORELEASER_CURRENT_TAG agar binary terkompilasi dengan versi yang benar
GORELEASER_CURRENT_TAG: ${{ env.FORK_VERSION }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: picoclaw-linux-amd64-${{ env.FORK_VERSION }}
path: dist/*.tar.gz
if-no-files-found: warn
- name: Create or Update GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Coba buat release baru, jika sudah ada maka upload asset saja
gh release create "${{ env.FORK_VERSION }}" dist/*.tar.gz \
--title "Fork Build ${{ env.FORK_VERSION }}" \
--notes "Automated release from branch ${{ github.ref_name }}." \
|| gh release upload "${{ env.FORK_VERSION }}" dist/*.tar.gz --clobber
- name: 📢 Notify Success
if: success()
run: |
curl \
-H "Title: Deploy picoclaw Linux AMD64 Success ✅" \
-H "Tags: white_check_mark,partying_face" \
-H "Priority: high" \
-d "Build artifact picoclaw-linux-amd64-${{ env.FORK_VERSION }} has been successfully uploaded." \
https://ntfy.sh/deploy-on-github-xasr6KBz47PjswPf53A78Fib
- name: 📢 Notify Failure
if: failure()
run: |
curl \
-H "Title: Deploy picoclaw Linux AMD64 Failed ❌" \
-H "Tags: x,skull" \
-H "Priority: urgent" \
-d "Build failed on branch ${{ github.ref_name }}. Please check the GitHub Actions logs." \
https://ntfy.sh/deploy-on-github-xasr6KBz47PjswPf53A78Fib

View file

@ -80,13 +80,15 @@ jobs:
path: dist/*.tar.gz path: dist/*.tar.gz
if-no-files-found: warn if-no-files-found: warn
- name: Create GitHub Release - name: Create or Update GitHub Release
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
# Coba buat release baru, jika sudah ada maka upload asset saja
gh release create "${{ env.FORK_VERSION }}" dist/*.tar.gz \ gh release create "${{ env.FORK_VERSION }}" dist/*.tar.gz \
--title "Fork Build ${{ env.FORK_VERSION }}" \ --title "Fork Build ${{ env.FORK_VERSION }}" \
--notes "Automated release from branch ${{ github.ref_name }}." --notes "Automated release from branch ${{ github.ref_name }}." \
|| gh release upload "${{ env.FORK_VERSION }}" dist/*.tar.gz --clobber
- name: 📢 Notify Success - name: 📢 Notify Success
if: success() if: success()

View file

@ -3,11 +3,11 @@ set -e
INSTALL_DIR="$HOME/.local/bin" INSTALL_DIR="$HOME/.local/bin"
BINARY_NAME="picoclaw" BINARY_NAME="picoclaw"
URL="https://github.com/sipeed/picoclaw/releases/latest/download/picoclaw_Linux_arm64.tar.gz"
GREEN='\033[0;32m' GREEN='\033[0;32m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
RED='\033[0;31m' RED='\033[0;31m'
YELLOW='\033[0;33m'
BOLD='\033[1m' BOLD='\033[1m'
RESET='\033[0m' RESET='\033[0m'
@ -23,18 +23,42 @@ print_error() {
echo -e "${RED}${RESET} $1" echo -e "${RED}${RESET} $1"
} }
print_warn() {
echo -e "${YELLOW}!${RESET} $1"
}
get_latest_version() { get_latest_version() {
local repo="$1" local repo="$1"
curl -sI "https://github.com/${repo}/releases/latest" 2>/dev/null | \ curl -sI "https://github.com/${repo}/releases/latest" 2>/dev/null | \
grep -i "location:" | sed 's|.*/tag/||' | tr -d '\r\n' grep -i "location:" | sed 's|.*/tag/||' | tr -d '\r\n'
} }
# Detect system architecture
detect_arch() {
local arch
arch=$(uname -m)
case "$arch" in
x86_64|amd64) echo "x86_64" ;;
aarch64|arm64) echo "arm64" ;;
armv7*|armhf) echo "armv7" ;;
*)
print_error "Unsupported architecture: $arch"
exit 1
;;
esac
}
echo "" echo ""
echo -e "${BOLD} PicoClaw Installer${RESET}" echo -e "${BOLD} PicoClaw Installer${RESET}"
echo " ─────────────────────" echo " ─────────────────────"
echo "" echo ""
# Detect architecture
ARCH=$(detect_arch)
print_success "Detected architecture: $ARCH"
# Ask user which version to install # Ask user which version to install
echo ""
echo -e "${BOLD}Select version to install:${RESET}" echo -e "${BOLD}Select version to install:${RESET}"
echo " 1) Original (sipeed/picoclaw)" echo " 1) Original (sipeed/picoclaw)"
echo " 2) Fork (muava12/picoclaw-fork)" echo " 2) Fork (muava12/picoclaw-fork)"
@ -42,17 +66,17 @@ echo ""
read -p "Choose [1-2] (default: 2): " version_choice < /dev/tty read -p "Choose [1-2] (default: 2): " version_choice < /dev/tty
if [[ "$version_choice" == "1" ]]; then if [[ "$version_choice" == "1" ]]; then
URL="https://github.com/sipeed/picoclaw/releases/latest/download/picoclaw_Linux_arm64.tar.gz"
REPO="sipeed/picoclaw" REPO="sipeed/picoclaw"
echo "" echo ""
print_step "Selected: ${BOLD}Original version${RESET}" print_step "Selected: ${BOLD}Original version${RESET}"
else else
URL="https://github.com/muava12/picoclaw-fork/releases/latest/download/picoclaw_Linux_arm64.tar.gz"
REPO="muava12/picoclaw-fork" REPO="muava12/picoclaw-fork"
echo "" echo ""
print_step "Selected: ${BOLD}Fork version${RESET}" print_step "Selected: ${BOLD}Fork version${RESET}"
fi fi
URL="https://github.com/${REPO}/releases/latest/download/picoclaw_Linux_${ARCH}.tar.gz"
print_step "Checking for latest version..." print_step "Checking for latest version..."
VERSION=$(get_latest_version "$REPO") VERSION=$(get_latest_version "$REPO")
if [ -n "$VERSION" ]; then if [ -n "$VERSION" ]; then
@ -102,7 +126,7 @@ fi
mkdir -p "$INSTALL_DIR" mkdir -p "$INSTALL_DIR"
print_success "Install directory: $INSTALL_DIR" print_success "Install directory: $INSTALL_DIR"
print_step "Downloading $BINARY_NAME (arm64)..." print_step "Downloading $BINARY_NAME ($ARCH)..."
cd /tmp cd /tmp
if command -v pv &> /dev/null; then if command -v pv &> /dev/null; then
curl -L "$URL" | pv -b -p -e -r > picoclaw.tar.gz curl -L "$URL" | pv -b -p -e -r > picoclaw.tar.gz
@ -122,12 +146,14 @@ print_success "Installed to $INSTALL_DIR/$BINARY_NAME"
print_success "Version: $VERSION" print_success "Version: $VERSION"
echo "" echo ""
PATH_CHANGED=false
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
print_step "Fixing PATH..." print_step "Fixing PATH..."
if ! grep -q "$INSTALL_DIR" ~/.bashrc 2>/dev/null; then if ! grep -q "$INSTALL_DIR" ~/.bashrc 2>/dev/null; then
echo '' >> ~/.bashrc echo '' >> ~/.bashrc
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
print_success "Added to ~/.bashrc" print_success "Added to ~/.bashrc"
PATH_CHANGED=true
else else
print_success "Already configured in ~/.bashrc" print_success "Already configured in ~/.bashrc"
fi fi
@ -136,6 +162,7 @@ if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo '' >> ~/.zshrc echo '' >> ~/.zshrc
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
print_success "Added to ~/.zshrc" print_success "Added to ~/.zshrc"
PATH_CHANGED=true
fi fi
export PATH="$INSTALL_DIR:$PATH" export PATH="$INSTALL_DIR:$PATH"
print_success "PATH updated for current session" print_success "PATH updated for current session"
@ -143,17 +170,12 @@ else
print_success "Already in PATH" print_success "Already in PATH"
fi fi
# Reload shell config so picoclaw is immediately available echo ""
print_step "Reloading shell config..." if [ "$PATH_CHANGED" = true ]; then
if [ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ]; then print_warn "Run this first to activate PATH:"
source "$HOME/.bashrc" echo ""
elif [ -n "$ZSH_VERSION" ] && [ -f "$HOME/.zshrc" ]; then echo -e " ${BOLD}source ~/.bashrc${RESET}"
source "$HOME/.zshrc" echo ""
elif [ -f "$HOME/.bashrc" ]; then
source "$HOME/.bashrc"
fi fi
print_success "Done" echo -e "Then run: ${BOLD}picoclaw onboard${RESET} to get started"
echo ""
echo -e "Run: ${BOLD}picoclaw onboard${RESET} to get started"
echo "" echo ""