一键自动发布ipa(更新svn,拷贝资源,压缩资源,加密图片资源,加密数据文件,加密lua脚本,编译代码,ipa签名,上传ftp)

程序员的生活要一切自动化,更要幸福^_^。

转载请注明出处http://www.cnblogs.com/mrblue/p/3885043.html

感谢小波同学

概述

平台:mac

例子工程:基于cocos2dx引擎的项目

事实:就是一组shell脚本和一些工具

我的 目录结构

Work

  |-----Project

      |---------cocos2dx

      |---------Game

            |---------proj.ios

            |---------Resoueces

  |-----tool

      |-----publish_package (这是我的打包工具存放目录)

          |-------package

              |-----------ios(ipa最终输出目录)

              |-----------android(apk最终输出目录,我还没完成,请各路大神帮忙完善)

          |-------script

          |-------tool

          |-------config.txt

          |-------publish_ipa.sh

          |-------upload_ftp.sh

一、配置文件  config.txt

说明:

1、这是所有配置,供其他脚本使用的一些常量,放这里统一管理

2、我们代码和资源svn目录是分开(这样有好有坏)

#! /bin/sh

#根目录
CurrentDir=`dirname $` #--------------------------------------SVN更新--------------------------------------
#SVN代码目录
SVN_Code=$CurrentDir/../.. #SVN资源目录
SVN_Resource=$CurrentDir/resource #要拷贝到的目标目录
Destiny_Dir_Resource=$SVN_Code/project/Game/Resources/resource #--------------------------------------压缩PNG--------------------------------------
CompressTool_Path=$CurrentDir/tool/ImageAlpha.app/Contents/Resources #--------------------------------------资源加密--------------------------------------
#加密工具目录
EncryptTool_Path=$CurrentDir/tool #png加密key
PngEncryptKey=xxxxxxxxxxxxxxxxxxxxx #data加密key
DataEncryptKey=xxxxxxxxxxxxxxxxxxxxxxxx #加密长度
EncryptDataLen= #--------------------------------------编译ipa--------------------------------------
ProjectRoot_Path=$SVN_Code/project #xcodeproj所在目录
XCodeProject_Path=$ProjectRoot_Path/Game/proj.ios #OutPut目录
TargetOutput_Path=$ProjectRoot_Path/bin/release/Game #Export目录
TargetExport_Path=$CurrentDir/package/ios #签名
IPA_SignIdentiy="xxxxxxxxxxxxxxxxxxx"
IPA_ProvisionIdentiy="xxxxxxxxxxxxxxxxxxxxx" #要生成的Target名字
ProjectTargets_Array=("Game_91" "Game_kuaiyong" "Game_pp" "Game_tongbu")

二、发布脚本publish_ipa.sh

说明:

1、如果你只想打出ipa,不想上传ftp,那就直接运行这个脚本,然后ipa自动生成在package/ios下

2、可以模块化执行,比如本次你只执行更新svn,但不需要执行资源加密等过程(之前已经弄好过了),那就把一些函数用#注释掉

#! /bin/sh

#根目录
RootDir=`dirname $` #加载配置文件
. $RootDir/config.txt #加载自动更新SVN脚本
. $RootDir/script/update_svn.sh #加载拷贝资源脚本
. $RootDir/script/copy_resouce.sh #加载压缩PNG脚本
. $RootDir/script/compress_png.sh #加载压缩PNG脚本
. $RootDir/script/encrypt.sh #lua脚本编译成字节码
. $RootDir/script/compile_luajit.sh #加载编译工程函数库
. $RootDir/script/build_ipa.sh function main()
{
updateSvn
copyResource
compressPNG
encryptPNG
encryptTableData
complieLuajit
buildProject
} main

3、更新svn    script/update_svn.sh

4、拷贝资源  script/copy_resouce.sh

说明:把签出的resource拷贝到Game/Resouece下

5、压缩png  script/compress_png.sh

说明:

1、使用的是pngquant,将全色png为256色的png8

2、工具所在目录是tool/ImageAlpha.app

#!/bin/sh

#压缩纹理

Compress_ProcessPath_Resource=$DestinyPath_Resource

#工具目录
Compress_ToolPath=$CompressTool_Path #压缩png
function compressPNG()
{
echo "-------Start Compress PNG : " $Compress_ProcessPath_Resource " ---------------" cd $Compress_ToolPath imageNumber=
tmpfilename=nill for filename in `find $Compress_ProcessPath_Resource -name "*.png"`
do
./pngquant --ext _tmp.png $filename
rm -rf $filename
imageNumber=$[imageNumber+]
done echo "start to rename Procedure!" for filename in `find $Compress_ProcessPath_Resource -name "*.png"`
do
tmpfilename=`echo ${filename%*_tmp*}`
mv $filename $tmpfilename.png
done echo "-------End Compress PNG with ImageNumber: " $imageNumber "Success Finished ! ---------------" cd $Script_RootDir
}

6、加密png和数据文件 script/encrypt.sh

说明:

1、加密方式是简单的抑或加密

2、可执行文件目录是 tool/EncryptPacker

3、png使用前EncryptDataLen(见config.txt)的长度字节加密,数据文件全部加密

4、如果你要给png加密,需要自己手动修改加载png的源文件代码(cocos2dx的在bool initWithImageFile(const char * strPath, EImageFormat imageType = kFmtPng)等地方)

5、这里给出机密工具( tool/EncryptPacker)的c++代码文件(因为使用的抑或加密,所以加密和解密代码一样的)

//
// main.cpp
// EncryptPacker
//
// Created by Blue on 14-6-4.
// Copyright (c) 2014年 Blue. All rights reserved.
// #include <iostream>
#include <string>
#include <fstream> using namespace std; const char* g_pszDesc = "Usage:\n\t./EncryptPacker inputfile key limitlength\n\nDesc:\n\tinputfile\t\tthe soucre file which will be encrypted(it will be replaced after encrypting)\n\tkey\t\t\t\tthe secret key(at least one character)\n\tlimitlength\t\tthe length of this file'data will be encrypted(0 means full lenth of the file)\n\nExample:\n\t./EncryptPacker a.txt xxxxxxxx 100\n"; int main(int argc, const char * argv[])
{
if (argc<)
{
std::cout << g_pszDesc;
return ;
} /*
for (int i=1; i<argc; i++)
{
cout<<argv[i]<<endl;
}
*/ const string strInputFile = argv[];
FILE* fp = fopen(strInputFile.c_str(), "r");
if (!fp)
{
cout<<"read file ["<<strInputFile.c_str()<<"] failed"<<endl;
return ;
} const string strKey = argv[];
size_t nKeyLen = strKey.length();
if (strKey.empty())
{
cout<<"input key"<<endl;
return ;
} int nLimitlength = atoi(argv[]);
if (nLimitlength<)
{
cout<<"limitlength must >= 0"<<endl;
return ;
} fseek(fp,,SEEK_END);
long lLen = ftell(fp);
fseek(fp,,SEEK_SET);
unsigned char* pBuffer = new unsigned char[lLen+];
pBuffer[lLen] = '\0';
fread(pBuffer,sizeof(unsigned char), lLen,fp);
fclose(fp); if (nLimitlength>)
{
for(int i=; i<nLimitlength && i<lLen; i++)
{
unsigned char cTemp = pBuffer[i];
pBuffer[i] = cTemp^strKey.at(i%nKeyLen);
}
}
else
{
for(int i=; i<lLen; i++)
{
unsigned char cTemp = pBuffer[i];
pBuffer[i] = cTemp^strKey.at(i%nKeyLen);
}
} FILE* wfp = fopen(strInputFile.c_str(), "w");
fwrite(pBuffer, lLen, , fp);
fclose(wfp); delete[] pBuffer; std::cout << "Encrypt ["<<strInputFile.c_str()<<"] successfully!\n"; return ;
}

7、加密lua脚本 script/compile_luajit.sh

说明:使用tool/luajit/luajit把lua脚本编译成字节码(不要搞什么自己加密了,这样做好处多多,自行百度)

8、生成ipa并签名 script/build_ipa.sh

9、上传ftp upload_ftp.sh(我还会自动帮你把dYSM文件备份,以备后面查看崩溃堆栈用)

使用方式:

一、只打ipa包,不上传ftp

1)那就打开命令行工具cd到publish_package,敲入sh publish_ipa.sh,回车

2)漫长等待后会在package/ios下生成ipa

二、生成ipa并上传ftp

1)那就打开命令行工具cd到publish_package,敲入sh upload_ftp.sh,回车

2)漫长等待后会在ftp你指定的目录下生成一个以今天日期命名的文件夹,里面躺着ipa,如20140804/Game_20140804.ipa和dSYM_20140804.tar(dSYM的压缩包)

最后附上工具套下载地址 publish_package

祝你们都幸福。

一键自动发布ipa(更新svn,拷贝资源,压缩资源,加密图片资源,加密数据文件,加密lua脚本,编译代码,ipa签名,上传ftp)的更多相关文章

  1. ZeroBrane Lua脚本编辑器代码自动补全

    简介         ZeroBrane Studio是一款支持代码提示.语法高亮.远程调试.代码分析.调试等功能的轻量级Lua IDE工具.可以去官网studio.zerobrane.com进行下载 ...

  2. SVN 代码下载,上传

    代码下载,如: svn co https://99.99.16.1:8080/svn/pavenas/webpy --username bg 代码上传,如: svn commit -m "备 ...

  3. 使用bat批处理文件定时自动备份oracle数据库并上传ftp服务器

    一.使用bat批处理文件备份oracle(前提是配置好oracle数据库客户端) @echo off set databasename=orcl  //数据库名 set username=ninic ...

  4. xcode 脚本编译,打包ipa

    1.清理工程 /usr/bin/xcodebuild -target targetName clean 2.编译 /usr/bin/xcodebuild -target targetName buil ...

  5. Cocos2d-x使用Luajit将Lua脚本编译为bytecode,实现加密 更新

    项目要求对lua脚本进行加密,查了一下相关的资料 ,得知lua本身能够使用luac将脚本编译为字节码(bytecode)从而实现加密,试了一下,确实可行. 以下是使用原生的lua解释器编译字节码: 1 ...

  6. 5分钟快速掌握Jenkins,项目一键自动部署

    5分钟快速掌握Jenkins,项目一键自动部署 目录 前言 Jenkins是什么? Jenkins环境安装搭建 Jenkins基本使用介绍 Jenkins快速构建项目,项目自动化部署 学习总结 前言 ...

  7. xcode8 上传ipa文件无法构建版本

    在xcode8 升级后上传ipa文件 需要设置一个安全提示,现在上传app store的方式为xcode或者 application loader 一.xcode 准备工作完成后点击Product-- ...

  8. PHP自动解压上传的rar文件

    PHP自动解压上传的rar文件   浏览:383 发布日期:2015/07/20 分类:功能实现 关键字: php函数 php扩展 大家都知道php有个zip类可直接操作zip压缩文件,可是用户有时候 ...

  9. winform 更新文件上传(一)

    using Common; using DevExpress.XtraEditors; using FileModel.UpLoad; using System; using System.Colle ...

随机推荐

  1. 两种html幻灯片效果

    650) this.width=650;" src="http://img1.51cto.com/attachment/201307/165757318.jpg" tit ...

  2. nodejs 相关

    1.错误 fs.js:543 return binding.rename(pathModule._makeLong(oldPath), 上传图片->图片改名->保存->在页面显示该图 ...

  3. jquery eval解析JSON中的注意点介绍

    在JS中将JSON的字符串解析成JSON数据格式,一般有两种方式:使用eval()函数.使用Function对象来进行返回解析,下面有个示例,感兴趣的朋友可以参考下   在JS中将JSON的字符串解析 ...

  4. php页面防重复提交方法总结

    1.提交按钮置disabled 当用户提交后,立即把按钮置为不可用状态.这种用js来实现. 提交前 复制代码 代码如下:         $("#submit").attr('di ...

  5. oracle中一些用法总结

    1. case用法: --简单case函数 case sex when '1' then 'boy' when '2' then 'girl' else '其他' end; --case搜索函数 ca ...

  6. 装X之写博客

    博客作用: 为了温习以前的知识,记录下 前几天和一个前辈聊天,说起看书总是前面学後面忘点的事情· 写个博客试试?

  7. select2

    .select2-container .select2-choice { height: 34px; line-height: 34px; } .自定义 组件高度 在css 里面设置 .select2 ...

  8. nyoj 4 ASCII码排序 java

    java输入字符:1.String s=sc.next(); 2.char a=s.charAt(0); 注意:package   java 中提交不能带package java代码: import ...

  9. 关于转录组比对STAR软件使用

    参考文章:http://weibo.com/p/23041883f77c940102vbkd?sudaref=passport.weibo.com 软件连接:https://github.com/al ...

  10. Linux(Ubuntu)安装并破解 SecureFX

    根据Linux(Ubuntu)下面SecureCRT 完全破解(地址:http://www.boll.me/archives/680) 添加了Linux(Ubuntu)下面SecureFX 完全破解, ...