前言
在上篇《基于Electron-Vue开发了一款美图搜罗器》文章中有提到过关于在自动化构建的方面花费了很长的时间,实际上这是一个相对比较头痛的问题,之前每次commit到github之后,travis-ci以及appveyor都会进行build,不过有时候我们就是修改了与业务无关的东西,比如readme之类的,不需要重新build,这个时候我们就需要使用条件构建,这里最好的办法就是通过推送tag来进行触发构建。
travis-ci
关于在travis-ci中,我在官方的文档中并没有找到关于通过tag来进行触发构建的说明,可以或许会有遗漏,后面在官方github仓库的issue中发现了有人曾经提出来过,具体可以参考:https://github.com/travis-ci/travis-ci/issues/6893,于是参考着改了之后我的.travis.yml
就是如下所示:
osx_image: xcode8.3 sudo: required dist: trusty language: c matrix: include: - os: osx if: tag IS present # 这里是添加的之后的部分 cache: directories: - node_modules - "$HOME/.electron" - "$HOME/.cache" addons: apt: packages: - libgnome-keyring-dev - icnsutils #- xvfb before_install: - mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([ "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi install: #- export DISPLAY=':99.0' #- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - nvm install 10 - curl -o- -L https://yarnpkg.com/install.sh | bash - source ~/.bashrc - npm install -g xvfb-maybe - yarn script: #- xvfb-maybe node_modules/.bin/karma start test/unit/karma.conf.js #- yarn run pack && xvfb-maybe node_modules/.bin/mocha test/e2e - npm run release branches: only: - master
appveyor
appveyor的可以参考官方的https://www.appveyor.com/docs/appveyor-yml/中可以看出,在appveyor.yml中添加skip_non_tags: true
即可使用tag来触发构建,于是改了之后我的appveyor.yml
为:
# Commented sections below can be used to run tests on the CI server # https://simulatedgreg.gitbooks.io/electron-vue/content/en/testing.html#on-the-subject-of-ci-testing version: 0.1.{build} branches: only: - master skip_non_tags: true image: Visual Studio 2017 platform: - x64 cache: - node_modules - '%APPDATA%\npm-cache' - '%USERPROFILE%\.electron' - '%USERPROFILE%\AppData\Local\Yarn\cache' init: - git config --global core.autocrlf input install: - ps: Install-Product node 8 x64 - git reset --hard HEAD - npm install - node --version build_script: - npm run release test: off
坑
当上面的配置好了之后,我以为到此我就可以愉快的使用git push --tags
来触发构建了,但是实际情况并不是那么如意,当我试过多次之后并没有触发构建,而是像一只死鱼一般寂静 。
后来终于看到一篇文章《更简单地用Travis自动发布GitHub Releases》中提到:
要注意,如果此前设置过CI的分支限制,tags: true不会生效。 因为,对Travis来说,Tag也算是一种branch。
branches: only: - master去掉以上代码块,否则自动发布将不会执行。
于是乎,我将travis-ci以及appveyor配置文件中的相关配置移除,再执行了一次git push --tags
,果不其然,成功了!
后记
关于持续构建是对于现在的软件编译发布必要的东西,它可以减少大量的重复性的工作而减少我们的工作量,所以未来我会将线上可以进行自动化构建服务全部都完成此操作,加油!
从知乎过来围观一下!
@木子溯
知乎?
博主的网站还是很不错的,不过更新要有节奏。还有就是博主,我建议你,网站的界面可以适当修整一下,例如,块的边框可以去掉,这样整站看起来才不会花,才会大气。今天看了你一篇文章解决了一些问题,谢谢。
@广东羊城技工学校 好的,感谢您的建议,由于近来业务繁忙,所以暂无精力来更新博客,谢谢您的支持!
能否换个友情链接
文章不错非常喜欢
可以参考官方的
@230个网赚博客 目前已经解决
非技术的路过。
加油!
@托管中心加盟 好的谢谢
SpringCloud使用Zuul出现“Forwarding error”错误解决方法
Chatroulette-全世界随机视频聊天网站
IntelliJ IDEA下将JavaWeb打包成war包并发布到tomcat步骤说明
LiRecord留言板系统V2.0正式版发布
SpringBoot打包成war包并放置在tomcat运行
SpringBoot+Shiro整合进行登录验证与权限控制
多风格自适应WordPress主题Puock正式开源!
非大众版WordPress纯代码实现阅读量统计
面包多WordPress插件 – 把你的文章变成付费版
git reset —hard后暂存区代码跑哪儿去了?