Skip to content

Build for Android

Build for Android #53

Workflow file for this run

name: Build for Android
on:
workflow_dispatch:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Git LFS
run: |
git lfs install
git lfs pull
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.x'
- name: Install and Initialize gomobile
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install gomobile bind
run: go get golang.org/x/mobile/bind@latest
- name: Create build directory
run: mkdir -p ./build
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
server-id: github
- name: Set up Android SDK
uses: android-actions/setup-android@v3
with:
packages: 'platforms;android-26'
- name: Build mobile package
run: |
gomobile bind -v -o ./build/mobile.aar -target=android -ldflags="-checklinkname=0" -androidapi 26 ./mobile
- name: Get Release Info
id: get-release-info
uses: actions/github-script@v7
with:
script: |
let releaseVersion = '0.0.0';
try {
const release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
releaseVersion = release.data.tag_name;
} catch (error) {
console.log('Error fetching latest release: ', error.message);
}
return releaseVersion;
- name: Print release
run: echo "Latest Release is ${{ steps.get-release-info.outputs.result }}"
- name: Deploy to GitHub Packages
run: |
mvn deploy:deploy-file \
-Dfile=./build/mobile.aar \
-DgroupId=land.fx \
-DartifactId=fulamobile \
-Dversion=${{ steps.get-release-info.outputs.result }} \
-Dpackaging=aar \
-DrepositoryId=github \
-Durl=https://maven.pkg.github.com/functionland/go-fula
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}