From effdc5f467a2bf640d0d1e1324350c0228e0d24c Mon Sep 17 00:00:00 2001 From: "louis.pontoise" Date: Fri, 14 Feb 2020 22:20:28 +0900 Subject: [PATCH] fix: feedback token injected during ci Github expires token in source code so we have to hide it away in CI (for now) --- .travis.yml | 2 +- Info.plist | 2 ++ alt-tab-macos.xcodeproj/project.pbxproj | 4 ++-- ...sion_in_app.sh => replace_environment_variables_in_app.sh} | 3 ++- src/ui/FeedbackWindow.swift | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) rename scripts/{set_version_in_app.sh => replace_environment_variables_in_app.sh} (57%) diff --git a/.travis.yml b/.travis.yml index 2cee8b81..3811b65e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ script: - npm ci - npx commitlint-travis - if [ $IS_RELEASE ]; then scripts/determine_version_and_changelog.sh; fi - - if [ $IS_RELEASE ]; then scripts/set_version_in_app.sh; fi + - if [ $IS_RELEASE ]; then scripts/replace_environment_variables_in_app.sh; fi - pod install - scripts/import_codesign_certificate_into_keychain.sh - xcodebuild -workspace alt-tab-macos.xcworkspace -scheme Release diff --git a/Info.plist b/Info.plist index eb901d43..bcbd505b 100644 --- a/Info.plist +++ b/Info.plist @@ -38,5 +38,7 @@ true SUPublicEDKey 2e9SQOBoaKElchSa/4QDli/nvYkyuDNfynfzBF6vJK4= + FeedbackToken + #FEEDBACK_TOKEN# diff --git a/alt-tab-macos.xcodeproj/project.pbxproj b/alt-tab-macos.xcodeproj/project.pbxproj index 49564c86..09e89c84 100644 --- a/alt-tab-macos.xcodeproj/project.pbxproj +++ b/alt-tab-macos.xcodeproj/project.pbxproj @@ -140,7 +140,7 @@ D04BAC159731F80FDAF4EA6C /* 1-row.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "1-row.jpg"; sourceTree = ""; }; D04BAC2FEF7248B7BF9579E2 /* CollectionViewFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewFlowLayout.swift; sourceTree = ""; }; D04BAC34CFD42A7F6F1F01C0 /* CGWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGWindow.swift; sourceTree = ""; }; - D04BAC6AFC7F06D1A567F27A /* set_version_in_app.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = set_version_in_app.sh; sourceTree = ""; }; + D04BAC6AFC7F06D1A567F27A /* replace_environment_variables_in_app.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = replace_environment_variables_in_app.sh; sourceTree = ""; }; D04BACABD048E62EBE4576CC /* DebugProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugProfile.swift; sourceTree = ""; }; D04BACD976030676FD0761D5 /* Windows.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Windows.swift; sourceTree = ""; }; D04BACE22DC907F03D193075 /* ShortcutsTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShortcutsTab.swift; sourceTree = ""; }; @@ -396,7 +396,7 @@ children = ( D04BA7ECCE728582D9ECA613 /* determine_version_and_changelog.sh */, D04BA4B5292629AA6B560216 /* package_and_notarize_release.sh */, - D04BAC6AFC7F06D1A567F27A /* set_version_in_app.sh */, + D04BAC6AFC7F06D1A567F27A /* replace_environment_variables_in_app.sh */, D04BAE93A5854C501639C640 /* update_homebrew_cask.sh */, D04BA5E819181CB83C5602C7 /* generate_selfsigned_codesign_certificate.sh */, D04BA0AAAE82C72855DBBA26 /* update_appcast.sh */, diff --git a/scripts/set_version_in_app.sh b/scripts/replace_environment_variables_in_app.sh similarity index 57% rename from scripts/set_version_in_app.sh rename to scripts/replace_environment_variables_in_app.sh index 1e4f7d03..a117983e 100755 --- a/scripts/set_version_in_app.sh +++ b/scripts/replace_environment_variables_in_app.sh @@ -3,5 +3,6 @@ set -exu version="$(cat $VERSION_FILE)" -# set the version in the app meta-data for the AppStore and app "Get Info" panel + sed -i '' -e "s/#VERSION#/$version/" Info.plist +sed -i '' -e "s/#FEEDBACK_TOKEN#/$FEEDBACK_TOKEN/" Info.plist diff --git a/src/ui/FeedbackWindow.swift b/src/ui/FeedbackWindow.swift index f7504ad1..a8667b08 100644 --- a/src/ui/FeedbackWindow.swift +++ b/src/ui/FeedbackWindow.swift @@ -1,6 +1,7 @@ import Cocoa class FeedbackWindow: NSWindow { + static let token = Bundle.main.object(forInfoDictionaryKey: "FeedbackToken") as! String var body: TextArea! var email: TextArea! var sendButton: NSButton! @@ -83,7 +84,7 @@ class FeedbackWindow: NSWindow { request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.addValue("application/json", forHTTPHeaderField: "Accept") // access token of the alt-tab-macos-bot github account, with scope repo > public_repo - request.addValue("token 231413d7bf0e6cc533aae851c83dca25afed86bb", forHTTPHeaderField: "Authorization") + request.addValue("token " + FeedbackWindow.token, forHTTPHeaderField: "Authorization") request.httpBody = try! JSONSerialization.data(withJSONObject: [ "title": "[In-app feedback]", "body": assembleBody()