Skip to content

Commit b16e5eb

Browse files
committed
CI: use quicksilver/qs-plugin-action
1 parent e771561 commit b16e5eb

File tree

1 file changed

+9
-149
lines changed

1 file changed

+9
-149
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: build-and-sign
22

33
on:
44
push:
@@ -7,152 +7,12 @@ on:
77
jobs:
88
build:
99
runs-on: macos-latest
10-
env:
11-
QS_BUILD_ONLY: 1
12-
QS_SOURCE_ROOT: "/tmp/git/quicksilver"
1310
steps:
14-
- uses: actions/checkout@v2
15-
with:
16-
submodules: recursive
17-
- name: Build plugin
18-
run: |
19-
set -Eeuf -o pipefail
20-
21-
log() {
22-
echo "$*" > /dev/stderr
23-
}
24-
25-
err() {
26-
log "error: $*"
27-
exit 1
28-
}
29-
30-
json() {
31-
# Usage: stdin is json content, $1 is python-formatted query
32-
# Example: `xcodebuild -list -json | json '["project"]["configurations"][0]'`
33-
python3 -c '
34-
import json
35-
import sys
36-
37-
stdin = sys.stdin.read()
38-
content = json.loads(stdin)
39-
40-
json_keys = sys.argv[1]
41-
output = eval(f"{content}{json_keys}")
42-
43-
# Strips quotes if there is a simple result
44-
if isinstance(output, str):
45-
print(output)
46-
# Pretty-print arrays and dicts
47-
else:
48-
print(json.dumps(output, indent=4))
49-
' "$1"
50-
}
51-
52-
configuration=Release
53-
54-
mkdir -p "${QS_SOURCE_ROOT}"
55-
git clone --recurse-submodules "https://github.com/quicksilver/Quicksilver.git" "${QS_SOURCE_ROOT}"
56-
pushd "${QS_SOURCE_ROOT}"
57-
58-
latest_tag=$(git tag --list --sort=creatordate | tail -n 1)
59-
git checkout "${latest_tag}"
60-
61-
pushd Quicksilver
62-
while [[ ! -x "/tmp/QS/build/${configuration}/Quicksilver.app/Contents/MacOS/Quicksilver" ]]; do
63-
xcodebuild \
64-
-quiet \
65-
-destination generic/platform=macos \
66-
-configuration "${configuration}" \
67-
-scheme 'Quicksilver Distribution' \
68-
build || true
69-
done
70-
popd
71-
popd
72-
73-
project=$(find . -maxdepth 1 -name '*.xcodeproj' -not -iname "*test.xcodeproj" -print -quit)
74-
75-
if [[ -z "${project}" ]]; then
76-
scheme_list=$(xcodebuild -list -json || true)
77-
else
78-
scheme_list=$(xcodebuild -list -json -project "${project}")
79-
fi
80-
81-
if [[ -z "${scheme_list}" ]]; then
82-
err "unable to determine scheme list"
83-
fi
84-
85-
scheme=$(json '["project"]["targets"][0]' <<< "${scheme_list}")
86-
log "Using default scheme: ${scheme}"
87-
88-
# Absence of a project can still build, but will error if `-project` is specified
89-
opts=(-configuration "${configuration}" -scheme "${scheme}")
90-
if [[ -n "${project}" ]]; then
91-
opts+=(-project "${project}")
92-
fi
93-
SETTINGS=$(xcodebuild "${opts[@]}" -showBuildSettings -json)
94-
xcodebuild build -quiet "${opts[@]}"
95-
PLUGIN_NAME=$(json '[0]["buildSettings"]["FULL_PRODUCT_NAME"]' <<< "${SETTINGS}")
96-
97-
echo "PLUGIN_NAME=${PLUGIN_NAME}" >> $GITHUB_ENV
98-
99-
log "Built ${PLUGIN_NAME} successfully"
100-
- name: Archive plugin
101-
working-directory: /tmp/QS/build/Release/Quicksilver.app/Contents/PlugIns/
102-
run: |
103-
tar -czvf "${{ env.PLUGIN_NAME }}.tar.gz" "${{ env.PLUGIN_NAME }}"
104-
- name: Upload components for sign action
105-
uses: actions/upload-artifact@v4
106-
with:
107-
name: UNSIGNED_PLUGIN
108-
path: /tmp/QS/build/Release/Quicksilver.app/Contents/PlugIns/${{ env.PLUGIN_NAME }}.tar.gz
109-
110-
sign:
111-
needs: build
112-
runs-on: macos-latest
113-
env:
114-
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
115-
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
116-
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
117-
118-
SIGNING_IDENTITY: ${{ secrets.SIGNING_IDENTITY }}
119-
steps:
120-
- name: Download targz artifact
121-
uses: actions/download-artifact@v4
122-
with:
123-
name: UNSIGNED_PLUGIN
124-
path: /tmp/QS/build/Release/
125-
- name: Unarchive artifact and set plugin name in env
126-
run: |
127-
cd /tmp/QS/build/Release
128-
tar -xzvf *.tar.gz
129-
rm -r *.tar.gz
130-
131-
# Set env.PLUGIN_NAME for use in other steps
132-
PLUGIN_NAME=$(find . -name '*.qsplugin' -exec basename {} \; -quit)
133-
echo "PLUGIN_NAME=${PLUGIN_NAME}" >> $GITHUB_ENV
134-
- name: Sign plugin
135-
working-directory: /tmp/QS/build/Release/
136-
run: |
137-
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development
138-
KEYCHAIN_PATH=${RUNNER_TEMP}/app-signing.keychain-db
139-
CERTIFICATE_PATH=${RUNNER_TEMP}/build_certificate.p12
140-
echo -n "${MACOS_CERTIFICATE}" | base64 --decode --output "${CERTIFICATE_PATH}"
141-
142-
security create-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_PATH}"
143-
security default-keychain -s "${KEYCHAIN_PATH}"
144-
security set-keychain-settings -lut 21600 "${KEYCHAIN_PATH}"
145-
146-
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_PATH}"
147-
148-
security import "${CERTIFICATE_PATH}" -P "${MACOS_CERTIFICATE_PASSWORD}" -A -t cert -f pkcs12 -k "${KEYCHAIN_PATH}"
149-
codesign --force -vvv --deep --sign "${SIGNING_IDENTITY}" *.qsplugin
150-
- name: Archive signed plugin
151-
working-directory: /tmp/QS/build/Release
152-
run: |
153-
tar -czvf "${{ env.PLUGIN_NAME }}.tar.gz" "${{ env.PLUGIN_NAME }}"
154-
- name: Upload document
155-
uses: actions/upload-artifact@v4
156-
with:
157-
name: ${{ env.PLUGIN_NAME }}
158-
path: /tmp/QS/build/Release/${{ env.PLUGIN_NAME }}.tar.gz
11+
- uses: quicksilver/qs-plugin-action@v1
12+
with:
13+
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
14+
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
15+
SIGNING_IDENTITY: ${{ secrets.SIGNING_IDENTITY }}
16+
17+
QS_PUSH_PLUGIN_USER: ${{ secrets.QS_PUSH_PLUGIN_USER }}
18+
QS_PUSH_PLUGIN_PASS: ${{ secrets.QS_PUSH_PLUGIN_PASS }}

0 commit comments

Comments
 (0)