Skip to content

Instantly share code, notes, and snippets.

@joshdholtz
Created April 1, 2022 03:04
Show Gist options
  • Save joshdholtz/397b232f3ca3739ba4dada2300450000 to your computer and use it in GitHub Desktop.
Save joshdholtz/397b232f3ca3739ba4dada2300450000 to your computer and use it in GitHub Desktop.
Fastfile for building and updating for Sparkle
# GitHub
FL_GITHUB_API_TOKEN=
FL_GITHUB_RELEASE_API_TOKEN=
APP_STORE_CONNECT_API_KEY_ISSUER_ID=
APP_STORE_CONNECT_API_KEY_KEY_ID=
APP_STORE_CONNECT_API_KEY_KEY_FILEPATH=fastlane/YOUR.p8
FL_NOTARIZE_BUNDLE_ID=
FL_NOTARIZE_ASC_PROVIDER=
<?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>Wassup Changelog</title>
<link>http://sparkle-project.org/files/sparkletestcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version REPLACE_SPARKLE_VERSION</title>
<link>https://sparkle-project.org</link>
<sparkle:version>REPLACE_SPARKLE_VERSION</sparkle:version>
<description>
<![CDATA[
REPLACE_SPARKLE_DESCRIPTION
]]>
</description>
<pubDate>Tue, 29 Mar 2022 15:20:11 +0000</pubDate>
<enclosure url="https://github.com/joshdholtz/wassup-swift-releases/releases/download/REPLACE_SPARKLE_VERSION/Wassup.app.zip" REPLACE_SPARKLE_SIGN_UPDATE />
</item>
</channel>
</rss>
require "dotenv"
before_all do
Dotenv.load ".env.secret"
app_store_connect_api_key
end
lane :clear do
FileUtils.rm_rf("../build")
end
lane :release do
build
deploy
end
lane :build do
gym(
xcargs: "-allowProvisioningUpdates",
export_method: "developer-id",
export_options: {
"signingStyle": "automatic",
},
skip_profile_detection: "true",
output_directory: "build",
derived_data_path: "build/derived_data"
)
app_path = File.absolute_path(Dir["../build/*.app"].first)
notarize(
package: app_path,
verbose: true
)
end
lane :deploy do
sparkle_path = File.absolute_path("../build/derived_data/SourcePackages/artifacts/Sparkle")
app_path = File.absolute_path(Dir["../build/*.app"].first)
zip_path = zip(path: app_path)
sparkle_output = sh("#{sparkle_path}/bin/sign_update #{zip_path}")
description = prompt(
text: "Changelog",
multi_line_end_keyword: "END"
)
version = get_version_number
appcast_content = File.read("appcast.xml.tmpl")
appcast_content.gsub!("REPLACE_SPARKLE_VERSION", version)
appcast_content.gsub!("REPLACE_SPARKLE_DESCRIPTION", description)
appcast_content.gsub!("REPLACE_SPARKLE_SIGN_UPDATE", sparkle_output)
require 'base64'
base64_content = Base64.encode64(appcast_content)
get_file = github_api(
http_method: "GET",
path: "/repos/joshdholtz/wassup-swift-releases/contents/appcast.xml",
)
sha = JSON.parse(get_file[:body])["sha"]
github_api(
http_method: "PUT",
path: "/repos/joshdholtz/wassup-swift-releases/contents/appcast.xml",
body: { message: "Update #{version}", content: base64_content, sha: sha }
)
set_github_release(
repository_name: "joshdholtz/wassup-swift-releases",
name: version,
tag_name: version,
description: description,
commitish: "main",
upload_assets: zip_path
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment