Skip to content

Deploy packages

Deploy packages #31

Workflow file for this run

# This workflow will deploy examples and other packages to the Ambient Cloud.
name: Deploy packages
on:
workflow_dispatch:
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
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: Rust cache
uses: Leafwing-Studios/cargo-cache@v1.1.0
- run: rustup target add --toolchain stable wasm32-wasi
- 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 (for branches)
# only commit and push if this is running in a branch
if: startsWith(github.ref, 'refs/heads/')
run: |
base_branch=${GITHUB_REF#refs/heads/}
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 }}"
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 (for nightly builds)
# only commit and push if this is running in a nightly build tag
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-nightly-')
run: |
base_branch=main
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 }}"
# 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
cargo cf release update-version ${version}
git commit -a -m "Revert version back to ${version}"
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}