Skip to content

Commit

Permalink
Merge pull request yanue#2 from yanue/master
Browse files Browse the repository at this point in the history
获得最新的代码
  • Loading branch information
snailbing committed Aug 20, 2019
2 parents 212feab + 152db48 commit 1e98ff1
Show file tree
Hide file tree
Showing 66 changed files with 3,920 additions and 1,116 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,6 @@ V2rayU.xcodeproj/xcuserdata
Pods
V2rayU.xcworkspace/xcuserdata
Build/v2ray-core
Podfile.lock
.DS_Store
.idea
Binary file added Build/V2rayUTool
Binary file not shown.
17 changes: 17 additions & 0 deletions Build/publish.sh
@@ -0,0 +1,17 @@
#!/bin/bash

# publish.sh
# V2rayU
#
# Created by yanue on 2019/7/18.
# Copyright © 2019 yanue. All rights reserved.
source ./release.sh


read -p "请输入版本描述: " release_note
pushRelease ${release_note}
generateAppcast ${release_note}
commit

rm -rf "${DMG_TMP}" "${APP_PATH}" "${V2rayU_RELEASE}"
echo "Done"
67 changes: 41 additions & 26 deletions Build/release.sh
Expand Up @@ -174,29 +174,44 @@ function downloadV2ray() {
rm -fr v2ray-macos.zip
}

echo "正在打包版本: V"${APP_Version}
read -n1 -r -p "请确认版本号是否正确 [Y/N]? " answer
case ${answer} in
Y | y ) echo
echo "你选择了Y";;
N | n ) echo
echo ""
echo "OK, goodbye"
exit;;
*)
echo ""
echo "请输入Y|N"
exit;;
esac

rm -fr ${DMG_FINAL} ${V2rayU_RELEASE}
updatePlistVersion
downloadV2ray
build
createDmg
read -p "请输入版本描述: " release_note
pushRelease ${release_note}
generateAppcast ${release_note}
commit
rm -rf "${DMG_TMP}" "${APP_PATH}" "${V2rayU_RELEASE}"
echo "Done"

function makeDmg() {
echo "正在打包版本: V"${APP_Version}
read -n1 -r -p "请确认版本号是否正确 [Y/N]? " answer
case ${answer} in
Y | y ) echo
echo "你选择了Y";;
N | n ) echo
echo ""
echo "OK, goodbye"
exit;;
*)
echo ""
echo "请输入Y|N"
exit;;
esac

rm -fr ${DMG_FINAL} ${V2rayU_RELEASE}
updatePlistVersion
downloadV2ray
build
createDmg
}

function publish() {
read -p "请输入版本描述: " release_note
pushRelease ${release_note}
generateAppcast ${release_note}
commit

rm -rf "${DMG_TMP}" "${APP_PATH}" "${V2rayU_RELEASE}"
echo "Done"
}


if [ "$1" = "publish" ]
then
publish
else
makeDmg
fi
141 changes: 141 additions & 0 deletions Build/test.sh
@@ -0,0 +1,141 @@
#!/bin/bash
# 打包,发布

APP_NAME="V2rayU"
INFOPLIST_FILE="Info.plist"
BASE_DIR=$HOME/swift/V2rayU
BUILD_DIR=${BASE_DIR}/Build
V2rayU_ARCHIVE=${BUILD_DIR}/V2rayU.xcarchive
V2rayU_RELEASE=${BUILD_DIR}/release
APP_Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${BASE_DIR}/${APP_NAME}/${INFOPLIST_FILE}")
DMG_FINAL="${APP_NAME}.dmg"
APP_TITLE="${APP_NAME} - V${APP_Version}"
AppCastDir=$HOME/swift/appcast

function build() {
echo "Building V2rayU."${APP_Version}
echo "Cleaning up old archive & app..."
rm -rf ${V2rayU_ARCHIVE} ${V2rayU_RELEASE}

echo "Building archive... please wait a minute"
xcodebuild -workspace ${BASE_DIR}/V2rayU.xcworkspace -config Release -scheme V2rayU -archivePath ${V2rayU_ARCHIVE} archive

echo "Exporting archive..."
xcodebuild -archivePath ${V2rayU_ARCHIVE} -exportArchive -exportPath ${V2rayU_RELEASE} -exportOptionsPlist ./build.plist

echo "Cleaning up archive..."
rm -rf ${V2rayU_ARCHIVE}

chmod -R 755 "${V2rayU_RELEASE}/${APP_NAME}.app/Contents/Resources/v2ray-core"
chmod -R 755 "${V2rayU_RELEASE}/${APP_NAME}.app/Contents/Resources/unzip.sh"
}

function createDmg() {
umount "/Volumes/${APP_NAME}"

############# 1 #############
APP_PATH="${V2rayU_RELEASE}/${APP_NAME}.app"
DMG_BACKGROUND_IMG="dmg-bg@2x.png"

DMG_TMP="${APP_NAME}-temp.dmg"

# 清理文件夹
echo "createDmg start."
rm -rf "${DMG_TMP}" "${DMG_FINAL}"
# 创建文件夹,拷贝,计算
SIZE=`du -sh "${APP_PATH}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`
# 容错处理
if [ $? -ne 0 ]; then
echo "Error: Cannot compute size of staging dir"
exit
fi
# 创建临时dmg文件
hdiutil create -srcfolder "${APP_PATH}" -volname "${APP_NAME}" -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"
echo "Created DMG: ${DMG_TMP}"

############# 2 #############
DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}"| egrep '^/dev/' | sed 1q | awk '{print $1}')

# 拷贝背景图片
mkdir /Volumes/"${APP_NAME}"/.background
cp "${BUILD_DIR}/${DMG_BACKGROUND_IMG}" /Volumes/"${APP_NAME}"/.background/
# 使用applescript设置一系列的窗口属性
echo '
tell application "Finder"
tell disk "'${APP_NAME}'"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {0, 0, 560, 297}
set viewOptions to the icon view options of container window
set arrangement of viewOptions to not arranged
set icon size of viewOptions to 80
set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG}'"
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
delay 1
set position of item "'${APP_NAME}'.app" of container window to {120, 120}
set position of item "Applications" of container window to {380, 120}
close
open
update without registering applications
delay 2
end tell
end tell
' | osascript

sync
# 卸载
hdiutil detach "${DEVICE}"

############# 3 #############
echo "Creating compressed image"
hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"

# appcast sign update
${AppCastDir}/bin/sign_update ${DMG_FINAL}

umount "/Volumes/${APP_NAME}"
}

function downloadV2ray() {
echo "正在查询最新版v2ray ..."
rm -fr v2ray-macos.zip v2ray-core
tag=$(curl --silent "https://api.github.com/repos/v2ray/v2ray-core/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "v2ray-core version: ${tag}"
url="https://github.com/v2ray/v2ray-core/releases/download/${tag}/v2ray-macos.zip"
echo "正在下载最新版v2ray: ${tag}"
curl -Lo v2ray-macos.zip ${url}

unzip -o v2ray-macos.zip -d v2ray-core
rm -fr v2ray-macos.zip
}

echo "正在打包版本: V"${APP_Version}
read -n1 -r -p "请确认版本号是否正确 [Y/N]? " answer
case ${answer} in
Y | y ) echo
echo "你选择了Y";;
N | n ) echo
echo ""
echo "OK, goodbye"
exit;;
*)
echo ""
echo "请输入Y|N"
exit;;
esac

rm -fr ${DMG_FINAL} ${V2rayU_RELEASE}
updatePlistVersion
downloadV2ray
build
createDmg
read -p "请输入版本描述: " release_note
pushRelease ${release_note}
generateAppcast ${release_note}
commit
rm -rf "${DMG_TMP}" "${APP_PATH}" "${V2rayU_RELEASE}"
echo "Done"
4 changes: 3 additions & 1 deletion Podfile
Expand Up @@ -10,8 +10,10 @@ target 'V2rayU' do
# Pods for V2rayU
pod 'Alamofire'
pod 'SwiftyJSON'
pod 'Preferences'
# master branch
pod 'Preferences', :git => 'https://github.com/sindresorhus/Preferences.git'
pod 'Sparkle'
pod 'QRCoder'
pod "GCDWebServer", '~> 3.5.2'

end
40 changes: 27 additions & 13 deletions Podfile.lock
@@ -1,32 +1,46 @@
PODS:
- Alamofire (4.7.3)
- Preferences (0.2.0)
- QRCoder (1.0.0)
- Sparkle (1.20.0)
- SwiftyJSON (4.2.0)
- Alamofire (4.8.2)
- GCDWebServer (3.5.2):
- GCDWebServer/Core (= 3.5.2)
- GCDWebServer/Core (3.5.2)
- Preferences (0.3.0)
- QRCoder (1.1.0)
- Sparkle (1.21.3)
- SwiftyJSON (5.0.0)

DEPENDENCIES:
- Alamofire
- Preferences
- GCDWebServer (~> 3.5.2)
- Preferences (from `https://github.com/sindresorhus/Preferences.git`)
- QRCoder
- Sparkle
- SwiftyJSON

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Alamofire
- Preferences
- GCDWebServer
- QRCoder
- Sparkle
- SwiftyJSON

EXTERNAL SOURCES:
Preferences:
:git: https://github.com/sindresorhus/Preferences.git

CHECKOUT OPTIONS:
Preferences:
:commit: e2e2aaba41b531a642934a17c9b37149dd1c294c
:git: https://github.com/sindresorhus/Preferences.git

SPEC CHECKSUMS:
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568
Preferences: ebc036a176a298cde835155c73251173768a2f8d
QRCoder: 488f6869fb89ffcc3de3b4de2dabd200a6573f3c
Sparkle: 48999e7ee032f05ca05e28451eadf4af8ede6b44
SwiftyJSON: c4bcba26dd9ec7a027fc8eade48e2c911f229e96
Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
GCDWebServer: ead88cd14596dd4eae4f5830b8877c87c8728990
Preferences: 865793c3914c4de086c809a504a4157b8968cb90
QRCoder: cbd2bee531cc86d286df7942334cfed94c803ae4
Sparkle: 3f75576db8b0265adef36c43249d747f22d0b708
SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7

PODFILE CHECKSUM: c8bfc44adeae40100cae3f20ce703eaa6666d947
PODFILE CHECKSUM: 58098d0825211da73cdc15b835005b970bed1875

COCOAPODS: 1.6.1

0 comments on commit 1e98ff1

Please sign in to comment.