Auto-updating the Mac beta

Howdy everyone! I’ve been a Drafts user for a while, and the Mac app is already establishing an important place in my desktop workflow. Fantastic work so far, Greg.

Is there any chance the Mac app will move to Sparkle or a similar framework for auto-updating the beta? I love using the app, but the beta install-and-reinstall process is less than ideal. Thanks!

The final app will only be distributed via the Mac App Store, so I have not taken time to incorporate other upgrade options solely for the beta. Perhaps sometime down the road, but there will be a production release in the App Store soon and that will be the best way keep current.

2 Likes

Well, as I am wont to do, I wrote a shell script that I use to keep the Drafts beta up-to-date.

So far it has worked very well for me.

You can find it here:

https://github.com/tjluoma/di/blob/master/di-drafts.sh

It only uses tools which come with macOS by default, so you don’t need to download/install anything else.

I don’t know what your level of comfort/expertise is with dealing with shell scripts on macOS, but feel free to reply here if you need help getting it set up.

The best/easiest way to use it is to use a launchd plist which will run it automatically once or twice a day. I can put one together if that would help (I’m on my iPad at the moment or else I would have just attached one to this post).

3 Likes

Thanks, Greg. That explanation makes sense.

And thanks for that script, tjluoma. It looks like it does exactly what I need.

If anyone else comes across this thread and wants an easy way to automate running that script, I use an app called Lingon 3 from the Mac App Store for easily creating plists like tjluoma described. In about 30 seconds, I had that script running on startup and every 4 hours.

Thanks again, everyone!

1 Like

I came looking for something similar. The link to tjluoma’s script appears to be broken. Does anyone know if it was moved or a better solution has since been developed? I created a partial solution with KM and Hazel, but it isn’t great

Is there still a Mac beta? I seem to have lost track.

I think that di-drafts.sh stopped working once Drafts for Mac arrived in the Mac App Store, but if there’s a new beta, I’ll be happy to take another look.

Beta info still here:

1 Like

Well, HTML scraping to get the version number means that this will break if the formatting of that page changes… however, until then, an updating script can be found at di-drafts-beta.sh.

# NOTE!

The beta will be installed to /Applications/Drafts Beta.app to allow the beta to be installed alongside the official release. This should hopefully avoid confusion and namespace collisions.

Installation

  1. Download di-drafts-beta.sh to your Mac.

  2. Save it to somewhere like /usr/local/bin/di-drafts-beta.sh

  3. Make it executable: chmod 755 /usr/local/bin/di-drafts-beta.sh

  4. (Optional) If you want it to run periodically, save the text block below to something like: ~/Library/LaunchAgents/com.tjluoma.update-drafts-beta.plist (where ~ is your home directory):

<?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.tjluoma.update-drafts-beta</string>
	<key>Program</key>
	<string>/usr/local/di/di-drafts-beta.sh</string>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/tmp/com.tjluoma.update-drafts-beta-stderr.txt</string>
	<key>StandardOutPath</key>
	<string>/tmp/com.tjluoma.update-drafts-beta-stdout.txt</string>
	<key>StartInterval</key>
	<integer>21600</integer>
</dict>
</plist>

Then run

launchctl load ~/Library/LaunchAgents/com.tjluoma.update-drafts-beta.plist

It will check for a new version every 21,600 seconds (aka 6 hours). You can adjust that time by editing the StartInterval key (replace 21600 with the number of seconds you want). Tip: There are 3600 seconds per hour. But you knew that already.

1 Like

If you want a more reliable way to check current beta version, this is where the app itself checks:

https://config.agiletortoise.com/drafts-mac/beta/build-status.json

It’s just a JSON file with the current beta build number:

{
	"latest-version": "26.2.2",
}
1 Like

Oh… well that’s about 10,000 times better.

I have updated the script to use that instead.

Thanks!

1 Like

I will say, for the record, it’s not a great idea to have both the production and beta versions installed, and it’s 100% a really bad idea to run both at the same time. They will both read-write from the same data stores and that could create some real problems. It also creates conflicts if you use URL schemes at all.

1 Like

Hrm… this makes me think that I should change the script to install to /Applications/Drafts.app (and refuse to install if a root-owned app already lives there).

Would you consider that a better idea?

Yes, I think so. People can always switch back to App Store version if they decide to get off beta, but have both is just likely to cause confusion.

1 Like

Ok, the script has been updated to:

  1. Install to the standard location of /Applications/Drafts.app

  2. Check to see if an existing /Applications/Drafts.app installation is from the Mac App Store, and (if so) warn the user that they must manually remove the version before using this script. The message also warns against installing both versions at the same time.

Here’s an example where I have the standard version installed and ran the update script:

di-drafts-beta: Outdated: 26.1.5 vs 26.2.2

WARNING! The version of Drafts found at ‘/Applications/Drafts.app’ is from the Mac App Store.

/usr/local/di/di-drafts-beta.sh can only install or update the beta version of Drafts.

If you wish to use the beta, you must first remove the Drafts.app from the Mac App Store.

Please note that having both versions installed is HIGHLY DISCOURAGED
and could cause data loss or corruption.

Please don’t do that.

Of course the Terminal can’t interpret Markdown, but it still gets the raw emphasis and bold characters.

2 Likes