Deploy web client #586
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: Deploy web client | |
on: | |
workflow_dispatch: {} | |
env: | |
PACKAGE_NAME: ambient-web-${{ github.sha }} | |
jobs: | |
build: | |
permissions: | |
id-token: write | |
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 | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
- name: Rust cache | |
uses: Leafwing-Studios/cargo-cache@v1.1.0 | |
- name: "Build campfire" | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package campfire --no-default-features | |
- name: "Build web client" | |
uses: actions-rs/cargo@v1 | |
with: | |
command: run | |
args: --package campfire --no-default-features web build --profile release --target standalone --pkg-name ${{ env.PACKAGE_NAME }} | |
- name: Upload package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ambient-web-standalone | |
path: ./web/${{ env.PACKAGE_NAME }} | |
- id: auth | |
name: Authenticate with Google Cloud | |
uses: google-github-actions/auth@v0 | |
with: | |
token_format: access_token | |
workload_identity_provider: projects/549180905870/locations/global/workloadIdentityPools/github-pool/providers/github-provider | |
service_account: github@ambient-733e7.iam.gserviceaccount.com | |
access_token_lifetime: 1800s | |
- name: Upload to Google Cloud | |
uses: google-github-actions/upload-cloud-storage@v1 | |
with: | |
path: "./web/${{ env.PACKAGE_NAME }}" | |
destination: "ambient-artifacts/ambient-web-clients" | |
- name: Upload Canary to Google Cloud | |
# Only upload canary builds on pushes to main | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') | |
uses: google-github-actions/upload-cloud-storage@v1 | |
with: | |
path: "./web/${{ env.PACKAGE_NAME }}" | |
destination: "ambient-artifacts/ambient-web-clients/ambient-canary" | |
parent: false | |
- name: Get tagged version | |
# ref example: refs/tags/v0.3.0-nightly-2023-09-05 | |
if: startsWith(github.ref, 'refs/tags/v') | |
shell: bash | |
run: echo "tagged_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
- name: Upload tagged version to Google Cloud | |
# Only upload if triggered for a tag | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: google-github-actions/upload-cloud-storage@v1 | |
with: | |
path: "./web/${{ env.PACKAGE_NAME }}" | |
destination: "ambient-artifacts/ambient-web-clients/ambient-web-${{ env.tagged_version }}" | |
parent: false |