Skip to content

Commit

Permalink
Prepare Tophat for signed distribution and updates (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfroms authored Sep 23, 2024
1 parent b6ef2bf commit d9b5578
Show file tree
Hide file tree
Showing 16 changed files with 341 additions and 74 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/appcast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Update Appcast

on:
release:
types: [published]

jobs:
update_appcast:
name: Update Appcast
runs-on: macos-14
permissions:
contents: write
pull-requests: write
steps:
- name: Select Xcode Version
run: sudo xcode-select -switch /Applications/Xcode_15.4.app

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}

- name: Install Dependencies
run: |
xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath ${{ runner.temp }}
echo "Adding Sparkle binary path to PATH..."
echo "${{ runner.temp }}/artifacts/sparkle/Sparkle/bin" >> $GITHUB_PATH
- name: Prepare Environment
env:
RELEASE_JSON: ${{ toJSON(github.event.release) }}
uses: actions/github-script@v7
with:
script: |
const path = require('path');
console.log('Finding release asset...');
const release = JSON.parse(process.env.RELEASE_JSON);
const asset = release.assets.find(({name}) => /Tophat-.*.zip/.test(name));
const releasesPath = path.join('${{ runner.temp }}', 'releases');
console.log('Exporting workflow variables...');
core.exportVariable('asset_name', asset.name);
core.exportVariable('asset_url', asset.browser_download_url);
core.exportVariable('releases_path', releasesPath);
core.exportVariable('downloaded_asset_path', path.join(releasesPath, asset.name));
core.exportVariable('release_notes_path', path.join(releasesPath, `${path.parse(asset.name).name}.html`));
- name: Download Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release download ${{ github.event.release.tag_name }} --pattern ${{ env.asset_name }} --output ${{ env.downloaded_asset_path }}

- name: Generate Release Notes
uses: actions/github-script@v7
env:
RELEASE_NOTES_PATH: ${{ env.release_notes_path }}
MARKDOWN_TEXT: ${{ github.event.release.body }}
with:
script: |
const fs = require('fs');
const result = await github.rest.markdown.render({
text: process.env.MARKDOWN_TEXT
});
const htmlWithoutLineBreaks = result.data.replace(/(\r\n|\n|\r)/gm, '');
fs.writeFileSync(process.env.RELEASE_NOTES_PATH, htmlWithoutLineBreaks);
- name: Update Appcast XML File
run: |
echo -n "${{ secrets.SPARKLE_SIGNING_SECRET }}" | generate_appcast \
--ed-key-file - \
--link "${{ github.event.repository.html_url }}" \
--download-url-prefix "${{ github.event.repository.html_url }}/releases/download/${{ github.event.release.tag_name }}/" \
-o appcast.xml \
--embed-release-notes \
${{ env.releases_path }}
- name: Commit and Push Updated Appcast
run: |
BRANCH_NAME="update-appcast/${{ github.event.release.tag_name }}"
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git add appcast.xml
git commit -am 'Update Appcast'
git push --set-upstream origin $BRANCH_NAME
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
- name: Create Pull Request
uses: actions/github-script@v7
env:
HEAD_BRANCH: ${{ env.branch_name }}
BASE_BRANCH: ${{ github.event.repository.default_branch }}
with:
script: |
const { repo, owner } = context.repo;
console.log('Creating pull request...');
const result = await github.rest.pulls.create({
title: 'Update Appcast for ${{ github.event.release.tag_name }} release',
owner,
repo,
head: process.env.HEAD_BRANCH,
base: process.env.BASE_BRANCH,
body: 'This auto-generated PR updates the Appcast for the ${{ github.event.release.tag_name }} release.'
});
console.log('Adding label...');
await github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['appcast']
});
2 changes: 1 addition & 1 deletion .github/workflows/xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
run: sudo xcode-select -switch /Applications/Xcode_15.4.app

- name: Run Tests
run: set -o pipefail && xcodebuild test -project Tophat.xcodeproj -scheme TophatTests -destination 'platform=macOS,arch=x86_64' | xcbeautify
run: set -o pipefail && xcodebuild test -project Tophat.xcodeproj -scheme TophatTests -destination 'platform=macOS,arch=arm64' CODE_SIGNING_ALLOWED=NO | xcbeautify
64 changes: 53 additions & 11 deletions Tophat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
80D71F2A2985C4EE0006E1BF /* ScreenCopyOnboardingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D71F292985C4EE0006E1BF /* ScreenCopyOnboardingItem.swift */; };
80D71F2C2985C69B0006E1BF /* OnboardingPopoverContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D71F2B2985C69B0006E1BF /* OnboardingPopoverContent.swift */; };
80D71F2E2985D11A0006E1BF /* CustomizeLocationsButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D71F2D2985D11A0006E1BF /* CustomizeLocationsButton.swift */; };
80DC0FD82C82225600E5C9EE /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 80DC0FD72C82225600E5C9EE /* Sparkle */; };
80DC0FDA2C822E7F00E5C9EE /* UpdateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80DC0FD92C822E7F00E5C9EE /* UpdateController.swift */; };
80EB5D45296F59100011DE5F /* FetchArtifactTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80EB5D44296F59100011DE5F /* FetchArtifactTask.swift */; };
80EB5D47296F59270011DE5F /* PrepareDeviceTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80EB5D46296F59270011DE5F /* PrepareDeviceTask.swift */; };
80EB5D49296F5AAF0011DE5F /* InstallApplicationTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80EB5D48296F5AAF0011DE5F /* InstallApplicationTask.swift */; };
Expand Down Expand Up @@ -312,6 +314,8 @@
80D71F292985C4EE0006E1BF /* ScreenCopyOnboardingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenCopyOnboardingItem.swift; sourceTree = "<group>"; };
80D71F2B2985C69B0006E1BF /* OnboardingPopoverContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingPopoverContent.swift; sourceTree = "<group>"; };
80D71F2D2985D11A0006E1BF /* CustomizeLocationsButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizeLocationsButton.swift; sourceTree = "<group>"; };
80DC0FD52C82202600E5C9EE /* TophatCtl.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TophatCtl.entitlements; sourceTree = "<group>"; };
80DC0FD92C822E7F00E5C9EE /* UpdateController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateController.swift; sourceTree = "<group>"; };
80EB5D44296F59100011DE5F /* FetchArtifactTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchArtifactTask.swift; sourceTree = "<group>"; };
80EB5D46296F59270011DE5F /* PrepareDeviceTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrepareDeviceTask.swift; sourceTree = "<group>"; };
80EB5D48296F5AAF0011DE5F /* InstallApplicationTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallApplicationTask.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -350,6 +354,7 @@
8090E268296775BE003106B9 /* Collections in Frameworks */,
80C18345290232D1008D3B80 /* TophatFoundation in Frameworks */,
80346F042BEBD527002F54BC /* AsyncAlgorithms in Frameworks */,
80DC0FD82C82225600E5C9EE /* Sparkle in Frameworks */,
7F4532AF251A6C4700F2CFC8 /* LoggingOSLog in Frameworks */,
809BD04729106F5E00FD4043 /* GoogleStorageKit in Frameworks */,
80D2799829005DD000F03649 /* TophatServer in Frameworks */,
Expand Down Expand Up @@ -530,6 +535,7 @@
children = (
807D7B112983576C007942B4 /* Commands */,
80ED3E5B29835A8900A734B7 /* Extensions */,
80DC0FD52C82202600E5C9EE /* TophatCtl.entitlements */,
807D7B102983576C007942B4 /* TophatCtl.swift */,
);
path = TophatCtl;
Expand Down Expand Up @@ -685,6 +691,7 @@
80CBACFE2989B8B100F778DD /* ShowOnboardingWindowAction.swift */,
80518F562984804C00FB8803 /* TophatCtlSymbolicLinkManager.swift */,
804F37FC2C7CEFB00005A869 /* TrustedHostAlert.swift */,
80DC0FD92C822E7F00E5C9EE /* UpdateController.swift */,
8020A6DD297F301700FEA490 /* URLHandler.swift */,
80A66D732981BD2200ECBCB6 /* UtilityPathPreferences.swift */,
);
Expand Down Expand Up @@ -724,6 +731,7 @@
B6AA44CE296DF8EF0017321C /* ZIPFoundation */,
80ED3E8E298421B400A734B7 /* TophatKit */,
80346F032BEBD527002F54BC /* AsyncAlgorithms */,
80DC0FD72C82225600E5C9EE /* Sparkle */,
);
productName = Tophat;
productReference = 7F35024F24A5060500EE76EA /* Tophat.app */;
Expand Down Expand Up @@ -777,7 +785,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 1530;
LastUpgradeCheck = 1540;
ORGANIZATIONNAME = Shopify;
TargetAttributes = {
7F35024E24A5060500EE76EA = {
Expand Down Expand Up @@ -810,6 +818,7 @@
B6AA44CD296DF8EF0017321C /* XCRemoteSwiftPackageReference "ZIPFoundation" */,
807D7B1429835795007942B4 /* XCRemoteSwiftPackageReference "swift-argument-parser" */,
80346F022BEBD527002F54BC /* XCRemoteSwiftPackageReference "swift-async-algorithms" */,
80DC0FD62C82225600E5C9EE /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 7F35025024A5060500EE76EA /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -915,6 +924,7 @@
80EB5D5D2970A25D0011DE5F /* UpdateIconTask.swift in Sources */,
80518F632984A64F00FB8803 /* OnboardingWindow.swift in Sources */,
80EB5D55297095890011DE5F /* TaskStatusMetadata.swift in Sources */,
80DC0FDA2C822E7F00E5C9EE /* UpdateController.swift in Sources */,
80D71F2E2985D11A0006E1BF /* CustomizeLocationsButton.swift in Sources */,
80629BFA293981A80077960E /* PinnedApplication.swift in Sources */,
80EB5D57297096FB0011DE5F /* InstallStatusMetadata.swift in Sources */,
Expand Down Expand Up @@ -1083,7 +1093,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1140,7 +1150,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand All @@ -1155,18 +1165,21 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CODE_SIGN_ENTITLEMENTS = Tophat/Tophat.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 29;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = A7XGC83MZE;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Tophat/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.10.0;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.Tophat;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1180,21 +1193,27 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CODE_SIGN_ENTITLEMENTS = Tophat/Tophat.entitlements;
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 29;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = A7XGC83MZE;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = Tophat/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.10.0;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.Tophat;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = Tophat;
SWIFT_VERSION = 5.0;
};
name = Release;
Expand All @@ -1204,16 +1223,17 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = A7XGC83MZE;
INFOPLIST_FILE = TophatTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.TophatTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1226,16 +1246,17 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = A7XGC83MZE;
INFOPLIST_FILE = TophatTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.TophatTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1247,9 +1268,12 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_ENTITLEMENTS = TophatCtl/TophatCtl.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
DEVELOPMENT_TEAM = A7XGC83MZE;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.tophatctl;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1261,11 +1285,16 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_ENTITLEMENTS = TophatCtl/TophatCtl.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
DEAD_CODE_STRIPPING = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = A7XGC83MZE;
ENABLE_HARDENED_RUNTIME = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.shopify.tophatctl;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
Expand Down Expand Up @@ -1369,6 +1398,14 @@
version = 1.0.4;
};
};
80DC0FD62C82225600E5C9EE /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.6.4;
};
};
B6AA44CD296DF8EF0017321C /* XCRemoteSwiftPackageReference "ZIPFoundation" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/weichsel/ZIPFoundation";
Expand Down Expand Up @@ -1435,6 +1472,11 @@
isa = XCSwiftPackageProductDependency;
productName = TophatServer;
};
80DC0FD72C82225600E5C9EE /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 80DC0FD62C82225600E5C9EE /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
80ED3E8E298421B400A734B7 /* TophatKit */ = {
isa = XCSwiftPackageProductDependency;
productName = TophatKit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"version" : "1.0.2"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "0ef1ee0220239b3776f433314515fd849025673f",
"version" : "2.6.4"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 1 addition & 1 deletion Tophat.xcodeproj/xcshareddata/xcschemes/Tophat.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
LastUpgradeVersion = "1540"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit d9b5578

Please sign in to comment.