diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml new file mode 100644 index 000000000..32e2f2c06 --- /dev/null +++ b/.github/workflows/ci_cd.yml @@ -0,0 +1,58 @@ +on: + push: + branches: + - master + - test-github-actions +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APPCENTER_SECRET: ${{ secrets.APPCENTER_SECRET }} + APPCENTER_TOKEN: ${{ secrets.APPCENTER_TOKEN }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + APPLE_P12_CERTIFICATE: ${{ secrets.APPLE_P12_CERTIFICATE }} + FEEDBACK_TOKEN: ${{ secrets.FEEDBACK_TOKEN }} + NETLIFY_WEBHOOK: ${{ secrets.NETLIFY_WEBHOOK }} + SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }} + GITHUB_EVENT_BEFORE: ${{ github.event.before }} + GITHUB_EVENT_AFTER: ${{ github.event.after }} + BUILD_DIR: ${{ github.workspace }} + XCODE_BUILD_PATH: DerivedData/Build/Products/Release + VERSION_FILE: VERSION.txt + APP_NAME: AltTab +jobs: + build: + runs-on: macos-12 + environment: production + steps: +# - env: +# GITHUB_CONTEXT: ${{ toJSON(github) }} +# run: echo "$GITHUB_CONTEXT" + - run: echo "IS_RELEASE=$(if [ \"$GITHUB_REF_NAME\" = \"master\" -a \"$GITHUB_EVENT_NAME\" = \"push\" ]; then echo true; else echo false; fi)" >> $GITHUB_ENV + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: sudo xcode-select -s /Applications/Xcode_13.4.1.app/Contents/Developer + - id: pre-checkout + env: + COMMITS: ${{ toJson(github.event.commits) }} + run: | + if [[ "${{ github.event_name }}" == "push" ]]; then + COUNT=$(( $(echo "$COMMITS" | jq length) + 1 )) + else + COUNT=1 + fi + echo "fetch-depth=$COUNT" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@v3 + with: + fetch-depth: ${{ steps.pre-checkout.outputs.fetch-depth }} + - run: scripts/print_env.sh + - run: scripts/pre_build_checks.sh + - run: scripts/ci_cd.sh + - id: set_tag_name + run: echo "tag_name=v"$(cat $VERSION_FILE)"" >> "$GITHUB_OUTPUT" + - uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.set_tag_name.outputs.tag_name }} + files: ${{ env.XCODE_BUILD_PATH }}/*.zip + - run: scripts/after_deploy.sh diff --git a/.travis.yml b/.travis.yml index 40b1bbfb7..66da8592b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,36 @@ -branches: - only: - - master - - develop -os: osx -osx_image: xcode13.4 -language: node_js -node_js: - - 16 -addons: - ssh_known_hosts: github.com - homebrew: - packages: - - vitorgalvao/tiny-scripts/cask-repair - update: true -env: - global: - - IS_RELEASE=$(if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then echo true; fi) - - XCODE_BUILD_PATH="DerivedData/Build/Products/Release" - - VERSION_FILE="VERSION.txt" - - APP_NAME="$(awk -F ' = ' '/PRODUCT_NAME/ { print $2; }' < config/base.xcconfig)" -install: true # disable default install -script: scripts/travis.sh -before_deploy: if [[ $TRAVIS_TEST_RESULT == 1 ]]; then echo "build failed; exiting to prevent deploy phases"; sleep 2; exit 1; fi -deploy: - provider: releases - token: - secure: wZUHfOs+JQ0ikNMJ8BnM+8fuoQdhgOEQpNd01ueZxe760GAAjSbq1icME8qaYJJMk1G6n14jo9ecEhzxF0XV8hSdy4WtikK7l5SXiOx5Efuh/tNscmHggGk235eLwQD9pglePZsP3xJUB1BHEj260rypkjnSx5kVOfLUeB1ASeg4+KdxZd2vXjwel+YQf+dYbNUYtwoWqjiLbqT1ao+0q04MPgD2c9jb+HnsA94LUGb44lPXqfUJ+xG2LxBpcDW/q1JhFXL/AmJb0dOOEVzzrBqfWysPukgPMONexZse4c3BBqkMI52ZuF3OoEVAffofmuGKiR5OoyU/hW17xi9jGeb79r+Xt4RdaJAgwcn7/7GtemYKUJp8jhLGsy9XZJShENX7UHTkP3L4iyOrd2Wz+ctZWAebyNReLt985/xTaplpDiQrPcKAuQNBa4sgWk5rIsf7Z0tcBfZau/fQl9Q4100xTbwC+GeAbL0IyXG3kVzQGsGllXHr/2JM1sj7rmKA7lmDlp7xiOBCPscn2YCT87U+F6VbYoNvnxne0igQOUwrvX4qa4XlYrUXDeHcyKku0m8znY74nOu+m6LXkIt8r29pi6Xac0/ZGMwKZRUvKg/skamWPRoy9DAVd8TBQW1c91oYKmqDQRy0eWnD6X1djcKywJ7WlSQDejebJql0h+o= - file_glob: true - file: "$XCODE_BUILD_PATH/*.zip" - skip_cleanup: true - on: - repo: lwouis/alt-tab-macos -after_deploy: scripts/after_deploy.sh +#branches: +# only: +# - master +# - test-github-actions +#os: osx +#osx_image: xcode13.4 +#language: node_js +#node_js: +# - 16 +#addons: +# ssh_known_hosts: github.com +# homebrew: +# packages: +# - vitorgalvao/tiny-scripts/cask-repair +# update: true +#env: +# global: +# - IS_RELEASE=$(if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then echo true; fi) +# - XCODE_BUILD_PATH="DerivedData/Build/Products/Release" +# - VERSION_FILE="VERSION.txt" +# - APP_NAME="$(awk -F ' = ' '/PRODUCT_NAME/ { print $2; }' < config/base.xcconfig)" +# - BUILD_DIR="$TRAVIS_BUILD_DIR" +#install: true # disable default install +#script: scripts/print_env_vars.sh +#script: scripts/print_env.sh && scripts/pre_build_checks.sh && scripts/ci_cd.sh +#before_deploy: if [[ $TRAVIS_TEST_RESULT == 1 ]]; then echo "build failed; exiting to prevent deploy phases"; sleep 2; exit 1; fi +#deploy: +# provider: releases +# token: +# secure: wZUHfOs+JQ0ikNMJ8BnM+8fuoQdhgOEQpNd01ueZxe760GAAjSbq1icME8qaYJJMk1G6n14jo9ecEhzxF0XV8hSdy4WtikK7l5SXiOx5Efuh/tNscmHggGk235eLwQD9pglePZsP3xJUB1BHEj260rypkjnSx5kVOfLUeB1ASeg4+KdxZd2vXjwel+YQf+dYbNUYtwoWqjiLbqT1ao+0q04MPgD2c9jb+HnsA94LUGb44lPXqfUJ+xG2LxBpcDW/q1JhFXL/AmJb0dOOEVzzrBqfWysPukgPMONexZse4c3BBqkMI52ZuF3OoEVAffofmuGKiR5OoyU/hW17xi9jGeb79r+Xt4RdaJAgwcn7/7GtemYKUJp8jhLGsy9XZJShENX7UHTkP3L4iyOrd2Wz+ctZWAebyNReLt985/xTaplpDiQrPcKAuQNBa4sgWk5rIsf7Z0tcBfZau/fQl9Q4100xTbwC+GeAbL0IyXG3kVzQGsGllXHr/2JM1sj7rmKA7lmDlp7xiOBCPscn2YCT87U+F6VbYoNvnxne0igQOUwrvX4qa4XlYrUXDeHcyKku0m8znY74nOu+m6LXkIt8r29pi6Xac0/ZGMwKZRUvKg/skamWPRoy9DAVd8TBQW1c91oYKmqDQRy0eWnD6X1djcKywJ7WlSQDejebJql0h+o= +# file_glob: true +# file: "$XCODE_BUILD_PATH/*.zip" +# skip_cleanup: true +# on: +# repo: lwouis/alt-tab-macos +#after_deploy: scripts/after_deploy.sh diff --git a/alt-tab-macos.xcodeproj/project.pbxproj b/alt-tab-macos.xcodeproj/project.pbxproj index 13826a0ad..8275b6dbc 100644 --- a/alt-tab-macos.xcodeproj/project.pbxproj +++ b/alt-tab-macos.xcodeproj/project.pbxproj @@ -289,6 +289,7 @@ 1C96189E451343DFB9F27C66 /* app_icons_align_thumbnails_center_light@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "app_icons_align_thumbnails_center_light@2x.jpg"; sourceTree = ""; }; 1C9618B3872558FBDE74D073 /* install_swiftformat.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = install_swiftformat.js; sourceTree = ""; }; 1C9618C8080211CBF882E4E0 /* thumbnails_hide_colored_circles_light@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "thumbnails_hide_colored_circles_light@2x.jpg"; sourceTree = ""; }; + 1C9619ABA703AADC5225C494 /* ci_cd.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = ci_cd.yml; sourceTree = ""; }; 1C9619DEB8B7905DBF9A6030 /* titles_hide_tabs_as_windows_light@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "titles_hide_tabs_as_windows_light@2x.jpg"; sourceTree = ""; }; 1C961A0A3EF637793B0F9B89 /* thumbnails_align_thumbnails_leading_light@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "thumbnails_align_thumbnails_leading_light@2x.jpg"; sourceTree = ""; }; 1C961A9B3F8ABA1ECFDF7C9F /* app_icons_hide_preview_focused_window_light@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "app_icons_hide_preview_focused_window_light@2x.jpg"; sourceTree = ""; }; @@ -360,6 +361,7 @@ BF0C864F182B6155A66D241D /* KeyRepeatTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyRepeatTimer.swift; sourceTree = ""; }; BF0C86C2BB70A8E05D2103CA /* cs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = cs; path = Localizable.strings; sourceTree = ""; }; BF0C86E06A44AC151FEA4903 /* sv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sv; path = InfoPlist.strings; sourceTree = ""; }; + BF0C8703C7489A44BEC4BCED /* pre_build_checks.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = pre_build_checks.sh; sourceTree = ""; }; BF0C87320241EAE01E38EF53 /* .periphery.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = .periphery.yml; sourceTree = ""; }; BF0C87897C24638DDE4A9889 /* app-icons-style.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "app-icons-style.jpg"; sourceTree = ""; }; BF0C87B913292EE53EDE4220 /* menubar-1.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = "menubar-1.svg"; sourceTree = ""; }; @@ -398,6 +400,7 @@ BF0C8B2EA9269BA0B79A525F /* sk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sk; path = Localizable.strings; sourceTree = ""; }; BF0C8BA452332236D972C60E /* ATShortcut.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ATShortcut.swift; sourceTree = ""; }; BF0C8BED805610C4F9C46A4A /* export_l10n_strings_to_poeditor.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = export_l10n_strings_to_poeditor.sh; sourceTree = ""; }; + BF0C8C0FF1B21F5F7CE16B79 /* print_env.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = print_env.sh; sourceTree = ""; }; BF0C8C4E74DCA631A049492A /* preferences-policies.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "preferences-policies.jpg"; sourceTree = ""; }; BF0C8C4F77466FB59071A71F /* sr */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sr; path = InfoPlist.strings; sourceTree = ""; }; BF0C8C5210ACA9FBFAE9C631 /* preferences-general.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "preferences-general.jpg"; sourceTree = ""; }; @@ -577,7 +580,7 @@ D04BAD40CE2D3A8AAC3819D0 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = file.gitignore; path = .gitignore; sourceTree = ""; }; D04BAD60C97E609A759E721E /* PoliciesTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PoliciesTab.swift; sourceTree = ""; }; D04BAD65AA870A49D2F89DBC /* ensure_generated_files_are_up_to_date.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ensure_generated_files_are_up_to_date.sh; sourceTree = ""; }; - D04BAD6700415D6F7C8B2BEE /* travis.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = travis.sh; sourceTree = ""; }; + D04BAD6700415D6F7C8B2BEE /* ci_cd.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ci_cd.sh; sourceTree = ""; }; D04BAD7008ED1D9CBC147A75 /* pull_request_template.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = pull_request_template.md; sourceTree = ""; }; D04BAD7D8F3CC2C36C8769C6 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = file.yml; path = .travis.yml; sourceTree = ""; }; D04BAD82F652C4ED5D8BF7AE /* 3 windows - 1 line - tall window.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "3 windows - 1 line - tall window.jpg"; sourceTree = ""; }; @@ -682,6 +685,14 @@ path = preferences; sourceTree = ""; }; + 1C961B4542D84D5B6E937B15 /* workflows */ = { + isa = PBXGroup; + children = ( + 1C9619ABA703AADC5225C494 /* ci_cd.yml */, + ); + path = workflows; + sourceTree = ""; + }; 4807A6C423A9CD190052A53E /* Frameworks */ = { isa = PBXGroup; children = ( @@ -1185,6 +1196,7 @@ D04BAD7008ED1D9CBC147A75 /* pull_request_template.md */, D04BA7A56A2009957C939159 /* ISSUE_TEMPLATE */, BF0C89F6EA16DD7322626E20 /* FUNDING.yml */, + 1C961B4542D84D5B6E937B15 /* workflows */, ); path = .github; sourceTree = ""; @@ -1367,7 +1379,7 @@ D04BAE93A5854C501639C640 /* update_homebrew_cask.sh */, D04BA0AAAE82C72855DBBA26 /* update_appcast.sh */, D04BA123744B0C27E9F54B05 /* codesign_sparkle_embedded_apps.sh */, - D04BAD6700415D6F7C8B2BEE /* travis.sh */, + D04BAD6700415D6F7C8B2BEE /* ci_cd.sh */, D04BA81B25C166EFB3223639 /* extract_l10n_strings.sh */, D04BA4FB0047656BEA21F1BE /* codesign */, D04BA19E22F2B73DB785E5DB /* subset_font.sh */, @@ -1387,6 +1399,8 @@ 1C9618B3872558FBDE74D073 /* install_swiftformat.js */, 1C961AD30050B3BAC2A8EDD4 /* swiftformat.js */, BF0C8BED805610C4F9C46A4A /* export_l10n_strings_to_poeditor.sh */, + BF0C8C0FF1B21F5F7CE16B79 /* print_env.sh */, + BF0C8703C7489A44BEC4BCED /* pre_build_checks.sh */, ); path = scripts; sourceTree = ""; diff --git a/scripts/travis.sh b/scripts/ci_cd.sh similarity index 74% rename from scripts/travis.sh rename to scripts/ci_cd.sh index 7af35367a..b0d988dc9 100755 --- a/scripts/travis.sh +++ b/scripts/ci_cd.sh @@ -1,15 +1,6 @@ #!/usr/bin/env bash -set -exu - -env | sort -xcodebuild -version -xcodebuild -workspace alt-tab-macos.xcworkspace -scheme Release -showBuildSettings | grep SWIFT_VERSION - -npm ci - -npx commitlint-travis -scripts/ensure_generated_files_are_up_to_date.sh +set -ex if [ $IS_RELEASE ]; then scripts/determine_version.sh @@ -17,8 +8,10 @@ if [ $IS_RELEASE ]; then fi scripts/codesign/setup_ci_master.sh +xcodebuild -version +xcodebuild -workspace alt-tab-macos.xcworkspace -scheme Release -showBuildSettings | grep SWIFT_VERSION xcodebuild -workspace alt-tab-macos.xcworkspace -scheme Release -derivedDataPath DerivedData -file "$TRAVIS_BUILD_DIR/$XCODE_BUILD_PATH/$APP_NAME.app/Contents/MacOS/$APP_NAME" +file "$BUILD_DIR/$XCODE_BUILD_PATH/$APP_NAME.app/Contents/MacOS/$APP_NAME" if [ $IS_RELEASE ]; then scripts/package_and_notarize_release.sh diff --git a/scripts/codesign/setup_ci_master.sh b/scripts/codesign/setup_ci_master.sh index 9e900d100..5dc11ef03 100755 --- a/scripts/codesign/setup_ci_master.sh +++ b/scripts/codesign/setup_ci_master.sh @@ -7,4 +7,4 @@ certificateFile="codesign" # Recreate the certificate from the secure environment variable echo "$APPLE_P12_CERTIFICATE" | base64 --decode > $certificateFile.p12 -scripts/codesign/import_certificate_into_new_keychain.sh "$certificateFile" "$APPLE_P12_CERTIFICATE_PASSWORD" +scripts/codesign/import_certificate_into_new_keychain.sh "$certificateFile" "" diff --git a/scripts/ensure_generated_files_are_up_to_date.sh b/scripts/ensure_generated_files_are_up_to_date.sh index 5af013de4..599629b76 100755 --- a/scripts/ensure_generated_files_are_up_to_date.sh +++ b/scripts/ensure_generated_files_are_up_to_date.sh @@ -1,6 +1,8 @@ -set -exu +set -ex -brew install jq +if [ "$TRAVIS" = true ] ; then + brew install jq +fi scripts/update_contributors.sh #scripts/import_l10n_strings_from_poeditor.sh scripts/extract_l10n_strings.sh diff --git a/scripts/pre_build_checks.sh b/scripts/pre_build_checks.sh new file mode 100755 index 000000000..20902b381 --- /dev/null +++ b/scripts/pre_build_checks.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -ex + +npm ci +if [ "$TRAVIS" = true ] ; then + npx commitlint-travis + npx commitlint +else + npx commitlint --from "$GITHUB_EVENT_BEFORE" --to "$GITHUB_EVENT_AFTER" --verbose +fi +scripts/ensure_generated_files_are_up_to_date.sh diff --git a/scripts/print_env.sh b/scripts/print_env.sh new file mode 100755 index 000000000..06465d87c --- /dev/null +++ b/scripts/print_env.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -ex + +pwd +env | sort +jq --version diff --git a/scripts/update_homebrew_cask.sh b/scripts/update_homebrew_cask.sh index c4938ba66..5c0dccc20 100755 --- a/scripts/update_homebrew_cask.sh +++ b/scripts/update_homebrew_cask.sh @@ -1,12 +1,17 @@ #!/usr/bin/env bash -set -exu +set -ex + +brew update +brew install vitorgalvao/tiny-scripts/cask-repair version="$(cat $VERSION_FILE)" -# add github ssh key -echo "$GITHUB_SSH_KEY" | base64 --decode > github_ssh -chmod 600 github_ssh -ssh-add -K github_ssh +if [ "$TRAVIS" = true ] ; then + # add github ssh key + echo "$GITHUB_SSH_KEY" | base64 --decode > github_ssh + chmod 600 github_ssh + ssh-add -K github_ssh +fi cask-repair --blind-submit --cask-version "$version" alt-tab