Figma Desktop app deployment - Scripting

erichughes
Contributor II

We are starting to use Figma and their installer is a stub installer which is a pain. They give some very base instructions for deployment. We want to use architecture specific builds and there is a "script" for accessing those. My scripting is very basic and I need a little help with getting the resent version acquired from one command into the argument for the download command. I can run them individually without issue manually replacing the latest_version with the "latest_version"

here are the commands provided.

latest_version=$(curl -fsSL "https://desktop.figma.com/mac/version.txt")
intel_url="https://desktop.figma.com/mac/Figma-${latest_version}.zip"
apple_silicon_url="https://desktop.figma.com/mac-arm/Figma-${latest_version}.zip"

I'm missing how to get what is echoed for latest_version into the curl for each architecture. This is what I tried without success. 

echo latest_version=$(curl -fsSL "https://desktop.figma.com/mac/version.txt") | curl -O -k https://desktop.figma.com/mac/Figma-${latest_version}.zip

Any pointers for the right direction are appreciated.

5 REPLIES 5

garybidwell
Contributor III

personally I just use DataJAR's autopkg recipe for Figma as it will create a installer with both architectures in a single pkg which can be used with Jamf, Munki etc.. for deployment

https://github.com/autopkg/dataJAR-recipes/tree/master/Figma

I saw the post title in the post list and had exactly the same thought.

erichughes
Contributor II

Thanks for the pointer. I was thinking the script might save some packaging when there is a update. Using Auto pkg is a good place to start, I will check out that recipe.

AVmcclint
Honored Contributor

If you're still interested in a script to download the architecture specific versions of apps, you can use this as a guide. This one handles .zip files. If you are trying to download apps that come in .dmgs, the process is similar but you have to add code for handling the dmg.

 

#!/bin/bash

# hardware architecture check. Possible answers are "arm" or "i386"
CPU=$(uname -p)
echo "hardware architecture is $CPU . Installing $CPU version of Figma"

latest_version=$(curl -fsSL "https://desktop.figma.com/mac/version.txt")
apple_silicon_url="https://desktop.figma.com/mac-arm/Figma-${latest_version}.zip"
intel_url="https://desktop.figma.com/mac/Figma-${latest_version}.zip"

if [[ -e /Applications/Figma.app ]]; then
	rm -Rf /Applications/Figma.app/
else
	echo "Figma is not present"
fi

# arm64 installation
arm_install()
{
	curl -L $apple_silicon_url > /Users/Shared/Figma-${latest_version}.zip 
	unzip /Users/Shared/Figma-${latest_version}.zip -d /Applications/
	sleep 3 
	rm -Rf /Users/Shared/Figma-${latest_version}.zip
}

# intel installation

intel_install()
{
	curl -L $intel_url > /Users/Shared/Figma-${latest_version}.zip 
	unzip /Users/Shared/Figma-${latest_version}.zip -d /Applications/
	sleep 3 
	rm -Rf /Users/Shared/Figma-${latest_version}.zip
}

if [ "$CPU" == arm ]
	then arm_install
	else intel_install
fi

echo "Finished installing $CPU version of Figma"

exit 0

 

erichughes
Contributor II

Thanks for that, wish I was better at scripting. I will report back which direction we go once it is implemented.