Skip to content

Commit b340046

Browse files
authored
Merge pull request #48 from qwertyyb/feature/sign
Feature/sign
2 parents a96d9b9 + dccf26a commit b340046

File tree

9 files changed

+149
-21
lines changed

9 files changed

+149
-21
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,33 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v1
14+
- uses: apple-actions/import-codesign-certs@v1
15+
with:
16+
p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
17+
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
1418
- name: update version
1519
run: |
1620
PRODUCT_SETTINGS_PATH=./YPaste/Info.plist
1721
version=$(git describe --tags `git rev-list --tags --max-count=1`)
1822
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $version" $PRODUCT_SETTINGS_PATH
1923
2024
- name: install depencies
21-
run: pod install
22-
- name: archive
23-
run: xcodebuild archive -workspace YPaste.xcworkspace -scheme YPaste -archivePath ./archive-YPaste -configuration Release
24-
- name: copy app && zip app && generate appcast
25+
run: |
26+
pod install
27+
npm install -g appdmg
28+
- name: build
2529
env:
2630
sparkle_key: ${{ secrets.sparkle_key }}
31+
run: ./scripts/build.sh
32+
- name: generate YPaste.zip
2733
run: |
28-
mkdir apps
29-
cp -a ./archive-YPaste.xcarchive/Products/Applications/*.app apps
3034
ditto -c -k --sequesterRsrc --keepParent apps/YPaste.app apps/YPaste.zip
3135
# rm -r ~/Library/Caches/Sparkle_generate_appcast/*
32-
./bin/generate_appcast -s $sparkle_key ./apps/
33-
c=$(cat ./apps/appcast.xml)
34-
echo $c | sed -e "s/url[^ ]*/url=\"https:\/\/github.com\/qwertyyb\/YPaste\/releases\/latest\/download\/YPaste.zip\"/g" > apps/appcast.xml
3536
3637
- name: upload release file
3738
uses: AButler/[email protected]
3839
with:
39-
files: 'apps/YPaste.zip'
40+
files: 'apps/dmg/YPaste.dmg'
4041
repo-token: ${{ secrets.GITHUB_TOKEN }}
4142

4243
- uses: actions/upload-artifact@v1

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v1
14+
- uses: apple-actions/import-codesign-certs@v1
15+
with:
16+
p12-file-base64: ${{ secrets.CERTIFICATES_P12 }}
17+
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
1418
- name: install depencies
1519
run: pod install
1620
- name: archive
17-
run: xcodebuild archive -workspace YPaste.xcworkspace -scheme YPaste -archivePath ./archive-YPaste -configuration Release
21+
run: |
22+
xcodebuild archive -workspace YPaste.xcworkspace -scheme YPaste -archivePath ./archive-YPaste -configuration Release
23+
echo "export archive"
24+
/usr/bin/xcodebuild -exportArchive -archivePath ./archive-YPaste.xcarchive -exportOptionsPlist "./scripts/ExportOptions.plist" -exportPath ./apps/ || { echo "Export Archive Failed : xcodebuild exportArchive action failed"; exit 1; }
1825
- name: copy app && zip app && generate appcast
1926
env:
2027
sparkle_key: ${{ secrets.sparkle_key }}
2128
run: |
22-
mkdir apps
23-
cp -a ./archive-YPaste.xcarchive/Products/Applications/*.app apps
2429
ditto -c -k --sequesterRsrc --keepParent apps/YPaste.app apps/YPaste.zip
2530
# rm -r ~/Library/Caches/Sparkle_generate_appcast/*
2631
./bin/generate_appcast -s $sparkle_key ./apps/

YPaste.xcodeproj/project.pbxproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,11 @@
591591
buildSettings = {
592592
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
593593
CODE_SIGN_ENTITLEMENTS = YPaste/YPaste.entitlements;
594-
CODE_SIGN_IDENTITY = "-";
595-
CODE_SIGN_STYLE = Automatic;
594+
CODE_SIGN_IDENTITY = "Developer ID Application";
595+
CODE_SIGN_STYLE = Manual;
596596
COMBINE_HIDPI_IMAGES = YES;
597-
DEVELOPMENT_TEAM = T68XK6867P;
597+
DEVELOPMENT_TEAM = FQ45888HUK;
598+
ENABLE_HARDENED_RUNTIME = YES;
598599
INFOPLIST_FILE = YPaste/Info.plist;
599600
LD_RUNPATH_SEARCH_PATHS = (
600601
"$(inherited)",
@@ -603,6 +604,7 @@
603604
MACOSX_DEPLOYMENT_TARGET = 10.15;
604605
PRODUCT_BUNDLE_IDENTIFIER = com.qwertyyb.YPaste;
605606
PRODUCT_NAME = "$(TARGET_NAME)";
607+
PROVISIONING_PROFILE_SPECIFIER = "";
606608
SWIFT_VERSION = 4.2;
607609
};
608610
name = Debug;
@@ -613,10 +615,11 @@
613615
buildSettings = {
614616
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
615617
CODE_SIGN_ENTITLEMENTS = YPaste/YPaste.entitlements;
616-
CODE_SIGN_IDENTITY = "-";
617-
CODE_SIGN_STYLE = Automatic;
618+
CODE_SIGN_IDENTITY = "Developer ID Application";
619+
CODE_SIGN_STYLE = Manual;
618620
COMBINE_HIDPI_IMAGES = YES;
619-
DEVELOPMENT_TEAM = T68XK6867P;
621+
DEVELOPMENT_TEAM = FQ45888HUK;
622+
ENABLE_HARDENED_RUNTIME = YES;
620623
INFOPLIST_FILE = YPaste/Info.plist;
621624
LD_RUNPATH_SEARCH_PATHS = (
622625
"$(inherited)",
@@ -625,6 +628,7 @@
625628
MACOSX_DEPLOYMENT_TARGET = 10.15;
626629
PRODUCT_BUNDLE_IDENTIFIER = com.qwertyyb.YPaste;
627630
PRODUCT_NAME = "$(TARGET_NAME)";
631+
PROVISIONING_PROFILE_SPECIFIER = "";
628632
SWIFT_VERSION = 4.2;
629633
};
630634
name = Release;

YPaste/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>Explosion v1.0.0-alpha</string>
2121
<key>CFBundleVersion</key>
22-
<string>103119</string>
22+
<string>103143</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSMinimumSystemVersion</key>

YPaste/YPaste.entitlements

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict/>
4+
<dict>
5+
<key>com.apple.security.cs.allow-jit</key>
6+
<true/>
7+
</dict>
58
</plist>

scripts/ExportOptions.plist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>method</key>
6+
<string>developer-id</string>
7+
<key>signingCertificate</key>
8+
<string>Developer ID Application</string>
9+
<key>teamID</key>
10+
<string>FQ45888HUK</string>
11+
</dict>
12+
</plist>

scripts/appdmg.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"title": "YPaste",
3+
"icon": "logo.icns",
4+
"format": "UDBZ",
5+
"contents": [
6+
{ "x": 448, "y": 344, "type": "link", "path": "/Applications" },
7+
{ "x": 192, "y": 344, "type": "file", "path": "../apps/YPaste.app" }
8+
]
9+
}

scripts/build.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# altool credentials.
2+
# AC_PASSWORD is the name of the keychain item with App Connect password
3+
# Grant access to Xcode if prompted by Xcode.
4+
AC_USERNAME="$APPLEID"
5+
AC_PASSWORD="$APPLE_PASSWORD"
6+
7+
if [[ $AC_USERNAME == "" ]]; then
8+
echo "error: no username"
9+
exit 1
10+
break
11+
fi
12+
13+
if [[ $AC_PASSWORD == "" ]]; then
14+
echo "error: no pass"
15+
exit 1
16+
break
17+
fi
18+
19+
# Do all of the work in a subdirectory of /tmp, and use a
20+
# unique ID so that there's no collision with previous builds.
21+
PRODUCT_NAME="YPaste"
22+
SCRIPTROOT=$(cd "$(dirname "$0")";pwd)
23+
SRCROOT=$(dirname "$SCRIPTROOT")
24+
ARCHIVE_PATH="$SRCROOT/archive-YPaste.xcarchive"
25+
EXPORT_PATH="$SRCROOT/apps"
26+
APP_PATH="$EXPORT_PATH/$PRODUCT_NAME.app"
27+
DMG_ROOT="$EXPORT_PATH/dmg"
28+
DMG_PATH="$DMG_ROOT/$PRODUCT_NAME.dmg"
29+
PRODUCT_BUNDLE_IDENTIFIER="com.qwertyyb.YPaste"
30+
31+
echo $SRCROOT
32+
33+
echo "clean build fold"
34+
rm -rf "$EXPORT_PATH"
35+
36+
echo "build archive"
37+
xcodebuild archive -workspace YPaste.xcworkspace -scheme YPaste -archivePath "$SRCROOT/archive-YPaste" -configuration Release || { echo "Archive and Notarization Failed : xcodebuild archive action failed"; exit 1; }
38+
39+
# Xcode doesn't show run script errors in build log.
40+
# Uncomment to save any messages aside.
41+
# exec > "/tmp/Xcode run script.log" 2>&1
42+
43+
# Ask xcodebuild(1) to export the app. Use the export options
44+
# from a previous manual export that used a Developer ID.
45+
46+
echo "export archive"
47+
/usr/bin/xcodebuild -exportArchive -archivePath "$ARCHIVE_PATH" -exportOptionsPlist "$SRCROOT/scripts/ExportOptions.plist" -exportPath "$EXPORT_PATH" || { echo "Export Archive Failed : xcodebuild exportArchive action failed"; exit 1; }
48+
49+
# Create a UDIF bzip2-compressed disk image.
50+
cd "$EXPORT_PATH/"
51+
mkdir dmg
52+
# mv "$APP_PATH" "$PRODUCT_NAME"
53+
54+
# /usr/bin/hdiutil create -srcfolder "$PRODUCT_NAME" -format UDBZ "$DMG_PATH"
55+
56+
echo "use appdmg create DMG file"
57+
appdmg "$SRCROOT/scripts/appdmg.json" "$DMG_PATH"
58+
59+
# Submit the finished deliverables for notarization. The "--primary-bundle-id"
60+
# argument is only used for the response email.
61+
echo "notarize app"
62+
xcrun altool --notarize-app --primary-bundle-id ${PRODUCT_BUNDLE_IDENTIFIER}.dmg -u "$AC_USERNAME" -p "$AC_PASSWORD" -f "$DMG_PATH" > "NotarizationUUIDs.log"
63+
64+
uuid=`cat $EXPORT_PATH/NotarizationUUIDs.log | grep -Eo '\w{8}-(\w{4}-){3}\w{12}$'`
65+
echo "uuid=$uuid"
66+
while true; do
67+
echo "checking for notarization..."
68+
69+
xcrun altool --notarization-info "$uuid" --username "$AC_USERNAME" --password "$AC_PASSWORD" &> check.log
70+
r=`cat check.log`
71+
t=`echo "$r" | grep "success"`
72+
f=`echo "$r" | grep "invalid"`
73+
if [[ "$t" != "" ]]; then
74+
echo "notarization done!"
75+
xcrun stapler staple "$APP_PATH"
76+
xcrun stapler staple "$DMG_PATH"
77+
echo "stapler done!"
78+
break
79+
fi
80+
if [[ "$f" != "" ]]; then
81+
echo "$r"
82+
exit 1
83+
fi
84+
echo "not finish yet, sleep 2m then check again..."
85+
sleep 120
86+
done
87+
88+
APPCAST_PATH="$DMG_ROOT/appcast.xml"
89+
echo "generate appcast.xml"
90+
"$SRCROOT/bin/generate_appcast" -s $sparkle_key "$DMG_ROOT"
91+
92+
echo "update appcast.xml download url"
93+
appcast=$(cat "$DMG_ROOT/appcast.xml")
94+
echo "$appcast" | sed -e "s/url[^ ]*/url=\"https:\/\/github.com\/qwertyyb\/YPaste\/releases\/latest\/download\/YPaste.dmg\"/g" > "$EXPORT_PATH/appcast.xml"

scripts/logo.icns

13 KB
Binary file not shown.

0 commit comments

Comments
 (0)