I have some codes written in golang which is compiled to aar and used as library in android app via gomobile. On my windows machine everything works well as I have everything configured correctly. Now I am trying to automate the build process using GitHub action and having trouble setting it up using ubuntu. The problems I am having I believe they are associated with setting PATH which on ubuntu.
Here is my workflow for building my project
on:
push:
branches:
- main
- actions
name: "Build & Release"
jobs:
generate:
name: Generate codes
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Installing go server dependencies
working-directory: server
run: |
go install
- name: setup-android-tools
uses: maxim-lobanov/setup-android-tools@v1
with:
packages: ndk;19.2.5345600
- name: Build aar
working-directory: server
run: |
go get -d golang.org/x/mobile/cmd/gomobile
gomobile init
gomobile bind -v -o ../client/app/libs/server.aar -target=android ./lib
- name: Push aar to release
uses: ncipollo/release-action@v1
with:
artifacts: "${{ matrix.dir }}/client/app/libs/*aar"
tag: v1.0.${{ github.run_number }}
token: ${{ secrets.GITHUB_TOKEN }}
The following is Go ENV as printed by setup-go
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/runner/.cache/go-build"
GOENV="/home/runner/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/runner/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/runner/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/hostedtoolcache/go/1.18.2/x64"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/hostedtoolcache/go/1.18.2/x64/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1913149098=/tmp/go-build -gno-record-gcc-switches"
And the following is the actual error I get when executing gomobile
go: downloading golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd go: downloading golang.org/x/mod v0.4.2 go: downloading golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098 go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 go: upgraded golang.org/x/mobile v0.0.0-20220504144722-50dca8fc073d => v0.0.0-20220518205345-8578da9835fd /home/runner/work/_temp/8ee34a1b-b28d-4781-9668-9aa41d593cce.sh: line 2: gomobile: command not found
How can I successifully build aar
using github action. Any help will be appreciated.
Here is GitHub repository for this project.
I would recommend using this step to configure gomobile
once you setup Go on your runner:
- name: Install Gomobile
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
go install golang.org/x/mobile/cmd/gobind@latest
go get golang.org/x/mobile/cmd/gobind
go get golang.org/x/mobile/cmd/gomobile
gomobile init
env:
GOPROXY: https://proxy.golang.org,direct
GO111MODULE: "on"
If it doesn't work out, I would be happy to look into this further and raise a fix on your GitHub repository itself :)