Skip to content

Deploy packages

Deploy packages #180

Workflow file for this run

# This workflow will deploy examples and other packages to the Ambient Cloud.
name: Deploy packages
on:
workflow_dispatch:
inputs:
base:
description: 'Base branch to merge update deployed packages to (no merging if not specified)'
required: false
default: ''
revert:
description: 'Revert version back to the specified version (you should only use this for merging to main)'
required: false
default: false
type: boolean
env:
CARGO_TERM_COLOR: always
CACHE_KEY: ambient-${{ github.sha }}
# token for gh command (other operations use GITHUB_TOKEN env var)
# we are using bot here so that the PR created by it triggers all the regular CI checks
GH_TOKEN: ${{ secrets.MOOSE_JOBS_GH_TOKEN }}
BOT_NAME: "Moose Jobs"
BOT_EMAIL: ${{ secrets.MOOSE_JOBS_EMAIL }}
jobs:
deploy-packages:
runs-on: ubuntu-22.04
env:
EXAMPLES_ASSETS_HOST: ${{ secrets.EXAMPLES_ASSETS_HOST }}
steps:
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y tree libasound2-dev libglib2.0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
libcairo-dev libgtk2.0-dev libsoup2.4-dev libgtk-3-dev libwebkit2gtk-4.0-dev xorg-dev ninja-build libxcb-render0-dev clang nodejs
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Add wasm32-wasi target
run: rustup target add --toolchain stable wasm32-wasi
- name: Add wasm32-unknown-unknown target
run: rustup target add --toolchain stable wasm32-unknown-unknown
- name: Rust cache
uses: Leafwing-Studios/cargo-cache@v1.1.0
- name: Install run (headless) dependencies
run: |
sudo apt-get update
sudo apt install -y libxcb-xfixes0-dev vulkan-validationlayers-dev mesa-vulkan-drivers libasound2-dev
- name: Download assets
run: cd guest/rust/examples/assets/unity && ./download.sh
- name: Deploy all packages
run: cargo campfire-slim package deploy-all --token ${{ secrets.AMBIENT_CLOUD_DEPLOY_TOKEN }} --include-examples
- name: Commit and push changed files without revert
if: github.event.inputs.base && !github.event.inputs.revert
run: |
base_branch=${{ github.event.inputs.base }}
branch=${base_branch}-deployed-${{ github.sha }}
git config --global user.name "${{ env.BOT_NAME }}"
git config --global user.email "${{ env.BOT_EMAIL }}"
git checkout -b ${branch}
git commit -a -m "Update deployed packages for ${{ github.sha }}" || true
git push --set-upstream origin ${branch}
pr_url=$(gh pr create --title "Update deployed packages for ${{ github.sha }}" --body "Deployed packages for ${{ github.sha }}" --base ${base_branch} --head ${branch})
gh pr merge --auto --squash --delete-branch ${pr_url}
- name: Commit and push changed files with version revert
if: github.event.inputs.base && github.event.inputs.revert
run: |
base_branch=${{ github.event.inputs.base }}
tag=${GITHUB_REF#refs/tags/}
branch=${tag}-deployed-${{ github.sha }}
git config --global user.name "${{ env.BOT_NAME }}"
git config --global user.email "${{ env.BOT_EMAIL }}"
git checkout -b ${branch}
git commit -a -m "Update deployed packages for ${{ github.sha }}" || true
# switch back to the main branch version
version_majminpat=$(echo ${tag} | sed -E -e 's/^v([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')
version=${version_majminpat}-dev
# We do not update the Ambient versions of the packages to ensure that the nightly that they were deployed with
# remains active + accurate
cargo cf release update-version ${version} --no-package-ambient-version-update
git commit -a -m "Revert version back to ${version}"
git push --set-upstream origin ${branch}
pr_url=$(gh pr create --title "Update version for ${{ github.sha }}" --body "Deployed packages for ${{ github.sha }} and updated version" --base ${base_branch} --head ${branch})
gh pr merge --auto --squash --delete-branch ${pr_url}