Add TinyGo build targets to Makefile and create GitHub Actions workflow for TinyGo builds

This commit is contained in:
2025-10-30 18:54:23 -05:00
parent bb98248830
commit 5369037a74
2 changed files with 77 additions and 1 deletions

66
.github/workflows/tinygo.yml vendored Normal file
View File

@@ -0,0 +1,66 @@
name: TinyGo Build
on:
push:
branches: [ "main", "master" ]
tags:
- 'v*'
pull_request:
branches: [ "main", "master" ]
jobs:
tinygo-build:
permissions:
contents: read
strategy:
matrix:
include:
- name: tinygo-default
target: ""
output: reticulum-go-tinygo
make_target: tinygo-build
- name: tinygo-wasm
target: wasm
output: reticulum-go.wasm
make_target: tinygo-wasm
runs-on: ubuntu-latest
outputs:
build_complete: ${{ steps.build_step.outcome == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.24'
- name: Install TinyGo
run: |
wget https://github.com/tinygo-org/tinygo/releases/download/v0.37.0/tinygo_0.37.0_amd64.deb
sudo dpkg -i tinygo_0.37.0_amd64.deb
- name: Build with TinyGo
id: build_step
run: |
make ${{ matrix.make_target }}
output_name="${{ matrix.output }}"
if [ -f "bin/${output_name}" ]; then
sha256sum "bin/${output_name}" | cut -d' ' -f1 > "bin/${output_name}.sha256"
echo "Built: ${output_name}"
echo "Generated checksum: bin/${output_name}.sha256"
else
echo "Build output not found: bin/${output_name}"
ls -la bin/
exit 1
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: bin/${{ matrix.output }}*

View File

@@ -15,7 +15,7 @@ MAIN_PACKAGE=./cmd/reticulum-go
ALL_PACKAGES=$$(go list ./... | grep -v /vendor/)
.PHONY: all build build-experimental experimental release lint bench bench-experimental bench-compare clean test coverage deps help
.PHONY: all build build-experimental experimental release lint bench bench-experimental bench-compare clean test coverage deps help tinygo-build tinygo-wasm
all: clean deps build test
@@ -105,6 +105,14 @@ build-all: build-linux build-windows build-darwin build-freebsd build-openbsd bu
run:
@./$(BUILD_DIR)/$(BINARY_NAME)
tinygo-build:
@mkdir -p $(BUILD_DIR)
tinygo build -o $(BUILD_DIR)/$(BINARY_NAME)-tinygo -size short $(MAIN_PACKAGE)
tinygo-wasm:
@mkdir -p $(BUILD_DIR)
tinygo build -target wasm -o $(BUILD_DIR)/$(BINARY_NAME).wasm $(MAIN_PACKAGE)
install:
$(GOMOD) download
@@ -133,4 +141,6 @@ help:
@echo " build-riscv - Build for RISC-V architecture (riscv64)"
@echo " build-all - Build for all platforms and architectures"
@echo " run - Run reticulum binary"
@echo " tinygo-build - Build binary with TinyGo compiler"
@echo " tinygo-wasm - Build WebAssembly binary with TinyGo compiler"
@echo " install - Install dependencies"