Build Semi-Static Binary #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Semi-Static Binary | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
required: true | |
type: string | |
no-upload: | |
type: boolean | |
description: "no-upload: if checked, don't upload" | |
workflow_call: | |
inputs: | |
release_type: | |
required: true | |
type: string | |
secrets: | |
GCP_CREDENTIALS: | |
required: true | |
jobs: | |
build_timestamp: | |
name: Set Build Timestamp | |
runs-on: ubuntu-latest | |
outputs: | |
date: ${{ steps.build_time.outputs.date }} | |
steps: | |
- name: Build Time | |
id: build_time | |
if: inputs.release_type == 'latest' | |
run: echo "date=`date +%Y%m%d%H%M%S`" >> $GITHUB_OUTPUT | |
static: | |
name: Antique Build | |
needs: build_timestamp | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: ubuntu-latest | |
image: ghcr.io/viamrobotics/antique2:amd64-cache | |
platform: linux/amd64 | |
- arch: ubuntu-small-arm | |
image: ghcr.io/viamrobotics/antique2:arm64-cache | |
platform: linux/arm64 | |
runs-on: ${{ matrix.arch }} | |
container: | |
image: ${{ matrix.image }} | |
options: --platform ${{ matrix.platform }} | |
timeout-minutes: 15 | |
outputs: | |
date: ${{ steps.build_date.outputs.date }} | |
env: | |
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: 'true' | |
steps: | |
- name: override nodejs | |
# note: the antique image intentionally has an old ubuntu with old GLIBC; github's node requires a newer one. | |
# we do this hack so actions can run. | |
run: ln --force --symbolic $(which node) /__e/node20/node | |
- 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 -R testbot:testbot . | |
sudo -Hu testbot bash -lc 'make clean-all' | |
- name: Authorize GCP Upload | |
uses: google-github-actions/auth@v1.1.1 | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: Build (PR) | |
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests') | |
run: | | |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" static-release' | |
- name: Upload Files (PR) | |
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests') | |
uses: google-github-actions/upload-cloud-storage@v0.10.4 | |
with: | |
headers: "cache-control: no-cache" | |
path: 'etc/packaging/static/deploy/' | |
destination: 'packages.viam.com/apps/viam-server/' | |
glob: 'viam-server-*' | |
parent: false | |
gzip: false | |
- name: Build (Latest) | |
if: inputs.release_type == 'latest' | |
run: | | |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="latest" BUILD_CHANNEL="${{needs.build_timestamp.outputs.date}}" static-release' | |
- name: Build (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 }}" static-release' | |
- 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') && !inputs.no-upload }} | |
uses: google-github-actions/upload-cloud-storage@v0.10.4 | |
with: | |
headers: "cache-control: no-cache" | |
path: 'etc/packaging/static/deploy/' | |
destination: 'packages.viam.com/apps/viam-server/testing/static/${{ steps.build_date.outputs.date }}/${{ github.sha }}/' | |
glob: 'viam-server-*' | |
parent: false | |
gzip: false | |
- name: Upload Manifest (Testing) | |
if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'push') && !inputs.no-upload }} | |
uses: google-github-actions/upload-cloud-storage@v0.10.4 | |
with: | |
headers: "cache-control: no-cache" | |
path: 'etc/packaging/static/manifest/' | |
destination: 'packages.viam.com/apps/viam-subsystems/testing/viam-server/${{ steps.build_date.outputs.date }}/${{ github.sha }}/' | |
glob: 'viam-server-*' | |
parent: false | |
gzip: false | |
output_summary: | |
name: Output Summary | |
runs-on: ubuntu-latest | |
needs: static | |
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests') | |
steps: | |
- name: Output Summary | |
run: | | |
channel="pr-${{ github.event.pull_request.number }}" | |
echo "### Built Static Binaries for ${channel}" >> $GITHUB_STEP_SUMMARY | |
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64" >> $GITHUB_STEP_SUMMARY | |
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY | |
static_test: | |
name: Static Test | |
if: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'push') && !inputs.no-upload }} | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [[ubuntu-latest], [ubuntu-small-arm], [pi4], [pi5]] | |
needs: static | |
runs-on: ${{ matrix.arch }} | |
timeout-minutes: 15 | |
outputs: | |
date: ${{ needs.static.outputs.date }} | |
steps: | |
- name: Clean Workspace | |
run: | | |
shopt -s dotglob | |
sudo chown -R `whoami` ./ | |
rm -rf ./* | |
- name: Test Static Binary | |
run: | | |
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/static/${{ needs.static.outputs.date }}/${{ github.sha }}/viam-server-${channel}-`uname -m` | |
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 ] | |
static_deploy: | |
name: Static Deploy | |
needs: static_test | |
if: ${{ !inputs.no-upload }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Authorize GCP | |
uses: google-github-actions/auth@v1.1.1 | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Publish Static Binary | |
run: | | |
gsutil mv "gs://packages.viam.com/apps/viam-server/testing/static/${{ needs.static_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-server/" | |
- name: Publish Subsystem Metadata | |
run: | | |
gsutil mv "gs://packages.viam.com/apps/viam-subsystems/testing/viam-server/${{ needs.static_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-subsystems/" | |
- name: Output Summary | |
run: | | |
channel="${{ github.ref_name }}" | |
# we call our main branch releases "latest" | |
if [ "$channel" == "main" ]; then | |
channel="latest" | |
fi | |
echo "### Built Static Binaries for ${channel}" >> $GITHUB_STEP_SUMMARY | |
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64" >> $GITHUB_STEP_SUMMARY | |
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64" >> $GITHUB_STEP_SUMMARY | |
echo "" >> $GITHUB_STEP_SUMMARY |