diff --git a/.travis.yml b/.travis.yml index f34ebc3ac..fcbc82d25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,11 @@ install: - npm ci script: - npx commitlint-travis + - ci/determine_version.sh + - ci/set_version_in_app.sh - xcodebuild + - ci/package_release.sh - if [ $TRAVIS_BRANCH == "master" ]; then npx semantic-release; fi -before_deploy: cd build/Release && zip -r alt-tab-macos.zip alt-tab-macos.app && tar czf alt-tab-macos.tar.gz alt-tab-macos.app deploy: provider: releases api_key: diff --git a/alt-tab-macos.xcodeproj/project.pbxproj b/alt-tab-macos.xcodeproj/project.pbxproj index d40a99276..f4e0295f7 100644 --- a/alt-tab-macos.xcodeproj/project.pbxproj +++ b/alt-tab-macos.xcodeproj/project.pbxproj @@ -31,6 +31,7 @@ D04BA32F25860B686DFE818A /* 3 windows - 1 line.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "3 windows - 1 line.jpg"; sourceTree = ""; }; D04BA35456DA0DDA74F9687E /* Keyboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Keyboard.swift; sourceTree = ""; }; D04BA4336B6004A0A99849AD /* package.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = package.json; sourceTree = ""; }; + D04BA4B5292629AA6B560216 /* package_release.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = package_release.sh; sourceTree = ""; }; D04BA4F23325560BC0BCDDB7 /* 7 windows - 2 lines - tall window.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "7 windows - 2 lines - tall window.jpg"; sourceTree = ""; }; D04BA51D43775E57CE91154A /* 3 windows - 1 line - wide window.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "3 windows - 1 line - wide window.jpg"; sourceTree = ""; }; D04BA56355579F78776E6D51 /* Cell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = ""; }; @@ -38,6 +39,7 @@ D04BA5E4A1745A481CEC1EBA /* 5 windows - 2 lines.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "5 windows - 2 lines.png"; sourceTree = ""; }; D04BA5E9CB56E27CC907F07D /* 6 windows - 2 lines.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "6 windows - 2 lines.png"; sourceTree = ""; }; D04BA7B6AAB0812631BBC7A2 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.info; path = Info.plist; sourceTree = ""; }; + D04BA7ECCE728582D9ECA613 /* determine_version.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = determine_version.sh; sourceTree = ""; }; D04BA82F792DF53958D92572 /* alt-tab-macos.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "alt-tab-macos.app"; sourceTree = BUILT_PRODUCTS_DIR; }; D04BA8924E1644C932B8CBAA /* preferences.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = preferences.json; sourceTree = ""; }; D04BA8DDB96B0A60C3394351 /* dark-background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dark-background.png"; sourceTree = ""; }; @@ -47,6 +49,7 @@ D04BAA44C837F3A67403B9DB /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; D04BAB6652494D7575057E86 /* 14 windows - 3 lines.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "14 windows - 3 lines.jpg"; sourceTree = ""; }; D04BAC02D60EF22D9CC7D969 /* commitlint.config.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = commitlint.config.js; sourceTree = ""; }; + D04BAC6AFC7F06D1A567F27A /* set_version_in_app.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = set_version_in_app.sh; sourceTree = ""; }; D04BAD1BED44EAEB77FED8A4 /* WindowManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowManager.swift; sourceTree = ""; }; D04BAD1C9F215BCCD3B620AC /* alt_tab_macos.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = alt_tab_macos.entitlements; sourceTree = ""; }; D04BAD40CE2D3A8AAC3819D0 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = file.gitignore; path = .gitignore; sourceTree = ""; }; @@ -84,6 +87,7 @@ D04BA4336B6004A0A99849AD /* package.json */, D04BA92541D46EA4F6943A72 /* package-lock.json */, D04BAFA277EAE3BDDDB61110 /* CHANGELOG.md */, + D04BA703DCD38D9757093312 /* ci */, ); sourceTree = ""; }; @@ -135,6 +139,16 @@ path = "alt-tab-macos"; sourceTree = ""; }; + D04BA703DCD38D9757093312 /* ci */ = { + isa = PBXGroup; + children = ( + D04BA7ECCE728582D9ECA613 /* determine_version.sh */, + D04BA4B5292629AA6B560216 /* package_release.sh */, + D04BAC6AFC7F06D1A567F27A /* set_version_in_app.sh */, + ); + path = ci; + sourceTree = ""; + }; D04BAA1C553891551B903DA7 /* logic */ = { isa = PBXGroup; children = ( diff --git a/alt-tab-macos/ui/Application.swift b/alt-tab-macos/ui/Application.swift index 0aecd7b44..2e29dbd85 100644 --- a/alt-tab-macos/ui/Application.swift +++ b/alt-tab-macos/ui/Application.swift @@ -94,6 +94,10 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) item!.button!.title = "AltTab" item!.menu = NSMenu() + item!.menu!.addItem( + withTitle: "Version #VERSION#", + action: nil, + keyEquivalent: "") item!.menu!.addItem( withTitle: "Quit \(ProcessInfo.processInfo.processName)", action: #selector(NSApplication.terminate(_:)), diff --git a/ci/determine_version.sh b/ci/determine_version.sh new file mode 100755 index 000000000..ac1b50230 --- /dev/null +++ b/ci/determine_version.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -ex + +semanticRelease=$(npx semantic-release --dry-run --ci false) +version=$(echo "$semanticRelease" | sed -nE 's/.+The next release version is (.+)/\1/p') + +echo "$version" > VERSION.txt diff --git a/ci/package_release.sh b/ci/package_release.sh new file mode 100755 index 000000000..53adaad8b --- /dev/null +++ b/ci/package_release.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -ex + +appName="AltTab" +version="$(cat VERSION.txt)" + +cd build/Release +mv "alt-tab-macos.app" "$appName.app" +zip -r "$appName-$version.zip" "$appName.app" +tar czf "$appName-$version.tar.gz" "$appName.app" diff --git a/ci/set_version_in_app.sh b/ci/set_version_in_app.sh new file mode 100755 index 000000000..6e7dd9113 --- /dev/null +++ b/ci/set_version_in_app.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -ex + +version="$(cat VERSION.txt)" +sed -i '' -e "s/#VERSION#/$version/" alt-tab-macos/ui/Application.swift