Skip to content

Instantly share code, notes, and snippets.

@huangyq23
Last active May 29, 2021 17:14
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save huangyq23/668e6d6fcccf714e802a to your computer and use it in GitHub Desktop.
Save huangyq23/668e6d6fcccf714e802a to your computer and use it in GitHub Desktop.
Sparkle+Github Release Integration, See http://yiqiu.me/2015/11/19/sparkle-update-on-github/

Sparkle+Github Release Integration

Blog post: http://yiqiu.me/2015/11/19/sparkle-update-on-github/

Install

  1. In the main branch, put release.sh and bump.sh into your Xcode project folder. You will need to modify the project name in the file. It also assumes both Archive and Product folder exists.
  2. Switch to gh-pages branch, put appcast.inc into _includes directory (You may need to create it yourself.) Again, modify the project name (line 15) in the file to your need.
  3. Put appcast.xml into the root directory
  4. Put the URL to the appcast.xml into the SUFeedURL of your Info.plist.
  5. Push the branches.

Usages

  1. Run bump.sh to bump the internal version, which will be today's date + 3 digit build sequence.
  2. Run release.sh to create a new release package following the naming convention.
  3. Follow normal release process and upload the zip file to Github
  4. Push to the gh-pages branch to trigger a rebuild. (http://stackoverflow.com/questions/24098792/how-to-force-github-pages-build)
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>{{ site.github.project_title }}</title>
<description>Most recent changes with links to updates.</description>
<language>en</language>
{% for release in site.github.releases %}
{% unless release.draft %}
{% unless release.prerelease and page.release_only %}
<item>
<title>{{ release.name }}</title>
<description><![CDATA[{{ release.body | markdownify }}]]></description>
<pubDate>{{ release.published_at | date_to_rfc822 }}</pubDate>
{% for asset in release.assets limit:1 %}
{% assign build_nums = asset.name | replace_first:'Project.v','' | replace_first:'.b',',' | remove_first:'.zip' | split:',' %}
{% if build_nums.size == 2 %}
{% assign version = build_nums[1] %}
{% assign short_version = release.tag_name | remove_first:'v' %}
{% else %}
{% assign version = release.tag_name | remove_first:'v' %}
{% endif %}
<enclosure
url="{{ asset.browser_download_url }}"
sparkle:version="{{ version }}"
{% if short_version %}sparkle:shortVersionString="{{ release.tag_name | remove_first:'v' }}"{% endif %}
length="{{ asset.size }}"
type="application/octet-stream" />
{% endfor %}
</item>
{% endunless %}
{% endunless %}
{% endfor %}
</channel>
</rss>
---
release_only: true
---
{%include appcast.inc %}
---
release_only: false
---
{%include appcast.inc %}
#!/bin/sh
PROJECT_DIR=$(pwd)/Project
INFOPLIST_FILE="Info.plist"
buildString=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildDate=$(echo $buildString | cut -c 1-8)
buildNumber=$(echo $buildString | cut -c 9-11)
today=$(date +'%Y%m%d')
if [[ $buildDate = $today ]]
then
buildNumber=$(($buildNumber + 1))
else
buildNumber=1
fi
buildString=$(printf '%s%03u' $today $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildString" "${PROJECT_DIR}/${INFOPLIST_FILE}"
{% assign build_nums = asset.name | replace_first:'Project.v','' | replace_first:'.b',',' | remove_first:'.zip' | split:',' %}
#!/bin/bash
PROJECT_NAME=Project
PROJECT_DIR=$(pwd)/$PROJECT_NAME
INFOPLIST_FILE="Info.plist"
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
CFBundleShortVersionString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
rm -rf Archive/*
rm -rf Product/*
xcodebuild clean -project $PROJECT_NAME.xcodeproj -configuration Release -alltargets
xcodebuild archive -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -archivePath Archive/$PROJECT_NAME.xcarchive
xcodebuild -exportArchive -archivePath Archive/$PROJECT_NAME.xcarchive -exportPath Product/$PROJECT_NAME.app -exportFormat app
zip -r "Product/$PROJECT_NAME.v${CFBundleShortVersionString}.b${CFBundleVersion}.zip" Product/$PROJECT_NAME.app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment