Skip to content

Build AppImage

Build AppImage #160

Workflow file for this run

name: Build AppImage
on:
workflow_dispatch:
inputs:
release_type:
required: true
type: string
workflow_call:
inputs:
release_type:
required: true
type: string
secrets:
GCP_CREDENTIALS:
required: true
jobs:
appimage:
name: AppImage Build
strategy:
fail-fast: false
matrix:
include:
- arch: [ubuntu-latest]
image: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
platform: linux/amd64
label: amd64
- arch: [buildjet-2vcpu-ubuntu-2204-arm]
image: ghcr.io/viamrobotics/rdk-devenv:arm64-cache
platform: linux/arm64
label: arm64
runs-on: ${{ matrix.arch }}
container:
image: ${{ matrix.image }}
options: --platform ${{ matrix.platform }}
timeout-minutes: 15
outputs:
date: ${{ steps.build_date.outputs.date }}
steps:
- name: Check out code
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: actions/checkout@v3
- name: Check out PR branch code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Clean and Fix Permissions
run: |
chown testbot:testbot -R .
sudo -Hu testbot bash -lc 'make clean-all'
- name: Authorize GCP Upload
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Build and Package (PR)
if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" appimage'
- name: Upload Files (PR)
if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/appimages/deploy/'
destination: 'packages.viam.com/apps/viam-server/'
glob: '*'
parent: false
gzip: false
- name: Build and Package (Latest)
if: inputs.release_type == 'latest'
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="latest" appimage'
- name: Build and Package (Tagged)
if: inputs.release_type == 'stable' || inputs.release_type == 'rc'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" appimage'
- name: Set Date
id: build_date
run: echo "date=`date +%F`" >> $GITHUB_OUTPUT
- name: Upload Files (Testing)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/appimages/deploy/'
destination: 'packages.viam.com/apps/viam-server/testing/appimage/${{ steps.build_date.outputs.date }}/${{ github.sha }}/'
glob: '*'
parent: false
gzip: false
appimage-static-32bit:
name: static 32-bit for appimage
runs-on: buildjet-2vcpu-ubuntu-2204-arm
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# note: we run this way instead of using rdk-devenv as the job's container because of https://github.com/actions/runner/issues/2115 (js-based actions install incomaptible node on 32-bit)
- name: build server
run: docker run --rm -v $PWD:/rdk ghcr.io/viamrobotics/rdk-devenv:armhf-cache sh -c "cd /rdk && make server-static"
- name: build aix
run: docker run --rm -v $PWD:/rdk ghcr.io/viamrobotics/rdk-devenv:armhf-cache sh -c 'cd /rdk && GOBIN=`pwd`/bin/`uname -s`-`uname -m` go install -ldflags "-s -w" -tags osusergo,netgo github.com/Otterverse/aix@latest'
- name: permissions
run: sudo chown -R $USER bin
# note: we do this because uname sees the arm64 kernel underneath the armhf container
- name: fix platform detection
run: mv bin/`uname -s`-`uname -m` bin/`uname -s`-armv7l
- uses: actions/upload-artifact@v3
with:
name: appimage-static-32bit
path: |
bin/*/viam-server
bin/*/aix
# note: this is a separate job because 1) appimage-builder doesn't work on 32-bit, 2) setup-python doesn't work on arm64
appimage-32bit:
runs-on: ubuntu-latest
needs: appimage-static-32bit
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- uses: actions/download-artifact@v3
with:
name: appimage-static-32bit
path: bin/
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: deps
run: pip install appimage-builder git+https://github.com/AppImageCrafters/appimage-builder.git@42d32f11496de43a9f6a9ada7882a11296e357ca
- name: build
env:
BUILD_CHANNEL: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
UNAME_M: armv7l
DPKG_ARCH: armhf
APPIMAGE_ARCH: armhf
run: make appimage-arch
- uses: actions/upload-artifact@v3
with:
name: appimage-armhf
path: etc/packaging/appimages/deploy
output_summary:
name: Output Summary
runs-on: ubuntu-latest
needs: appimage
if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
steps:
- name: Display Download Links
run: |
channel="pr-${{ github.event.pull_request.number }}"
echo "### Built AppImages for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
appimage_test:
name: AppImage Test
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
arch: [[ubuntu-latest], [buildjet-2vcpu-ubuntu-2204-arm], [arm64, pi4]]
needs: appimage
runs-on: ${{ matrix.arch }}
timeout-minutes: 15
outputs:
date: ${{ needs.appimage.outputs.date }}
steps:
- name: Clean Workspace
run: |
shopt -s dotglob
sudo chown -R `whoami` ./
rm -rf ./*
- name: Test AppImage
run: |
if echo "${{ matrix.arch[0] }}" | grep -q ubuntu; then
sudo apt-get install -y libfuse2
fi
channel="${{ github.ref_name }}"
# we call our main branch releases "latest"
if [ "$channel" = "main" ]; then
channel="latest"
fi
export TEST_DIR=`mktemp -d -t test-viam-server-XXXXXX`
cd $TEST_DIR
curl -o viam-server https://storage.googleapis.com/packages.viam.com/apps/viam-server/testing/appimage/${{ needs.appimage.outputs.date }}/${{ github.sha }}/viam-server-${channel}-`uname -m`.AppImage
chmod 755 viam-server
export RAND_PORT=$((30000 + $RANDOM))
echo "{\"network\": {\"bind_address\":\"localhost:${RAND_PORT}\"}}" > test.json
./viam-server -config test.json &
curl --retry 5 --retry-delay 5 --retry-connrefused localhost:$RAND_PORT
export RET1=$?
kill %%
wait $!
export RET2=$?
cd - && rm -rf $TEST_DIR
[ $RET1 == 0 ] && [ $RET1 == 0 ]
appimage_deploy:
name: AppImage Deploy
needs: [appimage-32bit]
# needs: [appimage_test, appimage-32bit]
runs-on: ubuntu-latest
env:
channel: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
steps:
- name: Authorize GCP
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- uses: actions/download-artifact@v3
with:
name: appimage-armhf
path: etc/packaging/appimages/deploy
- name: deploy 32-bit
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: etc/packaging/appimages/deploy/viam-server-${{ env.channel }}-armhf.AppImage
destination: 'packages.viam.com/apps/viam-server/'
parent: false
- name: short-circuit
run: exit 1
- name: Publish AppImage
run: |
gsutil mv "gs://packages.viam.com/apps/viam-server/testing/appimage/${{ needs.appimage_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-server/"
- name: Output Summary
run: |
echo "### Built AppImages for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "- armhf: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-armhf.AppImage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY