Skip to content

Commit

Permalink
ci: switch to github actions (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Nov 2, 2024
1 parent 9d1349b commit 946ebe8
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 55 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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
- uses: softprops/action-gh-release@v1
with:
files: ${{ env.XCODE_BUILD_PATH }}/*.zip
- run: scripts/after_deploy.sh
70 changes: 36 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 16 additions & 2 deletions alt-tab-macos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
1C96189E451343DFB9F27C66 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "[email protected]"; sourceTree = "<group>"; };
1C9618B3872558FBDE74D073 /* install_swiftformat.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = install_swiftformat.js; sourceTree = "<group>"; };
1C9618C8080211CBF882E4E0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "[email protected]"; sourceTree = "<group>"; };
1C9619ABA703AADC5225C494 /* ci_cd.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = ci_cd.yml; sourceTree = "<group>"; };
1C9619DEB8B7905DBF9A6030 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "[email protected]"; sourceTree = "<group>"; };
1C961A0A3EF637793B0F9B89 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "[email protected]"; sourceTree = "<group>"; };
1C961A9B3F8ABA1ECFDF7C9F /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "[email protected]"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -360,6 +361,7 @@
BF0C864F182B6155A66D241D /* KeyRepeatTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyRepeatTimer.swift; sourceTree = "<group>"; };
BF0C86C2BB70A8E05D2103CA /* cs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = cs; path = Localizable.strings; sourceTree = "<group>"; };
BF0C86E06A44AC151FEA4903 /* sv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sv; path = InfoPlist.strings; sourceTree = "<group>"; };
BF0C8703C7489A44BEC4BCED /* pre_build_checks.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = pre_build_checks.sh; sourceTree = "<group>"; };
BF0C87320241EAE01E38EF53 /* .periphery.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = .periphery.yml; sourceTree = "<group>"; };
BF0C87897C24638DDE4A9889 /* app-icons-style.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "app-icons-style.jpg"; sourceTree = "<group>"; };
BF0C87B913292EE53EDE4220 /* menubar-1.svg */ = {isa = PBXFileReference; lastKnownFileType = file.svg; path = "menubar-1.svg"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -398,6 +400,7 @@
BF0C8B2EA9269BA0B79A525F /* sk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sk; path = Localizable.strings; sourceTree = "<group>"; };
BF0C8BA452332236D972C60E /* ATShortcut.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ATShortcut.swift; sourceTree = "<group>"; };
BF0C8BED805610C4F9C46A4A /* export_l10n_strings_to_poeditor.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = export_l10n_strings_to_poeditor.sh; sourceTree = "<group>"; };
BF0C8C0FF1B21F5F7CE16B79 /* print_env.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = print_env.sh; sourceTree = "<group>"; };
BF0C8C4E74DCA631A049492A /* preferences-policies.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "preferences-policies.jpg"; sourceTree = "<group>"; };
BF0C8C4F77466FB59071A71F /* sr */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sr; path = InfoPlist.strings; sourceTree = "<group>"; };
BF0C8C5210ACA9FBFAE9C631 /* preferences-general.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "preferences-general.jpg"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -577,7 +580,7 @@
D04BAD40CE2D3A8AAC3819D0 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = file.gitignore; path = .gitignore; sourceTree = "<group>"; };
D04BAD60C97E609A759E721E /* PoliciesTab.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PoliciesTab.swift; sourceTree = "<group>"; };
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 = "<group>"; };
D04BAD6700415D6F7C8B2BEE /* travis.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = travis.sh; sourceTree = "<group>"; };
D04BAD6700415D6F7C8B2BEE /* ci_cd.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ci_cd.sh; sourceTree = "<group>"; };
D04BAD7008ED1D9CBC147A75 /* pull_request_template.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = pull_request_template.md; sourceTree = "<group>"; };
D04BAD7D8F3CC2C36C8769C6 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = file.yml; path = .travis.yml; sourceTree = "<group>"; };
D04BAD82F652C4ED5D8BF7AE /* 3 windows - 1 line - tall window.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "3 windows - 1 line - tall window.jpg"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -682,6 +685,14 @@
path = preferences;
sourceTree = "<group>";
};
1C961B4542D84D5B6E937B15 /* workflows */ = {
isa = PBXGroup;
children = (
1C9619ABA703AADC5225C494 /* ci_cd.yml */,
);
path = workflows;
sourceTree = "<group>";
};
4807A6C423A9CD190052A53E /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1185,6 +1196,7 @@
D04BAD7008ED1D9CBC147A75 /* pull_request_template.md */,
D04BA7A56A2009957C939159 /* ISSUE_TEMPLATE */,
BF0C89F6EA16DD7322626E20 /* FUNDING.yml */,
1C961B4542D84D5B6E937B15 /* workflows */,
);
path = .github;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 = "<group>";
Expand Down
15 changes: 4 additions & 11 deletions scripts/travis.sh → scripts/ci_cd.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/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
scripts/replace_environment_variables_in_app.sh
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/codesign/setup_ci_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ""
6 changes: 4 additions & 2 deletions scripts/ensure_generated_files_are_up_to_date.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions scripts/pre_build_checks.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions scripts/print_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -ex

pwd
env | sort
jq --version
15 changes: 10 additions & 5 deletions scripts/update_homebrew_cask.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 946ebe8

Please sign in to comment.