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.

15 REPLIES 15

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

 

How this script will work if Figma is running. How I will kill the process. I create a package via .dmg with composer but now it is not working after upgrade to Ventura. it is getting Figma desktop app is corrupted. But workaround if we rightclick on the icon from dock and then click open that start working and this need to do only 1st time, which is wired. any suggestion.

 

You can get highly detailed in how to kill the Figma app, but the simplest way I have found is to add 

 

killall Figma

 

right before the

# arm64 installation

section of the script. If Figma isn't running, the command will just fail silently. If Figma is running, it will kill the process and make for a safe install. 

 

erichughes
Contributor II

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

sharif_khan
Contributor II

The way I deploy 

1. Download the latest version as .dmg

2. Copy that .app to application folder and package through composer

3. change the ownership of the app

4. Add a script to kill running app

5. Deploy through policy that resolve the issue.

erichughes
Contributor II

We ended up using the script above pretty much as is to deploy the app. Works good but there is no update functionality. The Figma site says to create a Figma group with users and change the app permissions for that group to be allowed Auto update functionality. That would be a pain in my opinion. I think adding a version checker to the script above would be a better way to do that and have the Policy with the script run weekly to check any version difference. Maybe I just need a version checker script separate that will add to a Smart Group that has the original script scoped. Just thinking out loud here, but how do you update Figma?

AVmcclint
Honored Contributor

What I did was to put the script in a payload-free package (https://github.com/rtrouton/Payload-Free-Package-Creator) and uploaded to Jamf. Then I created a patching policy for Figma. When I see there's a new version, I define the next patch using the exact same package. When Jamf detects that a user has an older version of Figma, it will "install" the package that only runs the above script that goes out and grabs whatever the latest version is since the download path for the current version stays the same. The only manual part is just paying attention to when Patch Management so I can create a new definition. 

AVmcclint
Honored Contributor

I have discovered that the version number that Figma puts on https://desktop.figma.com/mac/version.txt is not updated in sync with the actual latest version that is available for download from their download page. After going back and forth with their support I got the following response:

Thanks for your patience here. The engineers have confirmed that it's expected that version.txt is the last place we update our version information. This is because we wait to update version.txt until the new version is fully rolled out so that admins can be confident that any unexpected issues have been resolved before they upgrade. 
 
If you've ever seen this data out of sync by more than one version, please let me know and I'll double-check again with them on what might be needed to prevent this confusion. 
 
They also noted that they're planning for more changes in future to better support enterprise rollouts including the possibility of a an RSS feed that admins can watch for updates and so they hope the enterprise deployment experience should continue to improve over the coming months. 
 

So what I did then was to make a launchAgent for myself to run locally on my Mac once an hour that runs a script in my /Library/Company/scripts/ folder that will compare the version of Figma that I have installed on my Mac with the version that is listed on their version.txt file on the Figma site. If the version in the version.txt page is newer than the version on my Mac, it will pop up a notification letting me know.

Here is the LaunchAgent that goes in ~/Library/LaunchAgents/ :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.company.figma.version</string>
	<key>ProgramArguments</key>
	<array>
		<string>/bin/sh</string>
		<string>/Library/Company/Scripts/Figma_version_check.sh</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StartInterval</key>
	<integer>3600</integer>
</dict>
</plist>

 Here is the script that goes in /Library/Company/Scripts/ :

#!/bin/bash

# Check if Figma is installed in /Applications
FIGMA_APP="/Applications/Figma.app"

# URL of the Figma version.txt file
FIGMA_VERSION_URL="https://desktop.figma.com/mac/version.txt"

# Path to the JamfHelper binary (make sure it's installed)
JAMF_HELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

# Check if Figma is installed
if [ -d "$FIGMA_APP" ]; then
    # Get the installed version of Figma
    INSTALLED_VERSION=$(/usr/bin/defaults read "$FIGMA_APP/Contents/Info.plist" CFBundleShortVersionString)

    # Fetch the remote version from the website
    REMOTE_VERSION=$(curl -s "$FIGMA_VERSION_URL")
    echo $REMOTE_VERSION

    # Compare versions using awk
    if [[ $(echo "$INSTALLED_VERSION" | awk -F. '{ printf("%03d%03d%03d\n", $1, $2, $3); }') -lt $(echo "$REMOTE_VERSION" | awk -F. '{ printf("%03d%03d%03d\n", $1, $2, $3); }') ]]; then
        # Display a message using JamfHelper
        "$JAMF_HELPER" -windowType utility -title "Figma Update Available" -icon "$FIGMA_APP/Contents/Resources/electron.icns" -description "There is a new version of Figma available. Please download the update." -button1 "OK" -defaultButton 1
    else
        echo "Figma is up to date."
    fi
else
    echo "Figma is not installed in /Applications."
fi

When I get the notification that there is an update available, then I update the Patch Policy in Jamf for that new version. This works for me at least until Figma changes their "enterprise deployment experience".

erichughes
Contributor II

Could the script above that you are putting in Company/Scripts be made into an extension attribute? Then you could set the application install policy Ongoing and scope it to a "Figma Out of Date" smart group?

Dr_Jones
New Contributor III

An EA to check for the latest version of Figma compared to what @erichughes  👍

 

#!/bin/bash

# Get the current version of Figma installed on the device
installedVersion=$(defaults read /Applications/Figma.app/Contents/Info.plist CFBundleShortVersionString)

# Get the latest version of Figma available from the website
latestVersion=$(curl -s https://desktop.figma.com/mac/version.txt)

# Compare the installed version to the latest version
if [ "$installedVersion" == "$latestVersion" ]; then
	echo "<result>Latest Version Installed</result>"
else
	echo "<result>Outdated Version Installed</result>"
fi

  

Dr_Jones
New Contributor III

Added an additional step to check if Figma is installed @erichughes 

 

 

#!/bin/bash

#Check to see if Figma is installed
if [ -d "/Applications/Figma.app" ]; then
    #Get the version of Figma installed
    figmaVersion=$(defaults read /Applications/Figma.app/Contents/Info.plist CFBundleShortVersionString)
    #Get the latest version of Figma from the website
    latestVersion=$(curl -s https://desktop.figma.com/mac/version.txt)
    #Compare the versions
    if [ "$figmaVersion" = "$latestVersion" ]; then
        echo "<result>Latest Version Installed</result>"
    else
        echo "<result>Outdated Version Installed</result>"
    fi
else
    echo "<result>Figma Not Installed</result>"
fi

 

 

erichughes
Contributor II

Thanks for the EA. I'll test that in my environment. Basically just want it to populate a smart group scoped to the policy containing the installer script, so it shows up in self service when a update is available.