forked from neverhood311/Stop-motion-OBJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
99 lines (91 loc) · 4.14 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
dist: xenial
os:
- linux
env:
global:
- BLENDER_CACHE=$HOME/.cache/blender
- BL_ADDON=Stop_motion_OBJ
jobs:
#- BLENDER_VERSION="2.80"
#- BLENDER_VERSION="2.81a"
#- BLENDER_VERSION="2.82a"
- BLENDER_VERSION="2.83"
language: python
python:
- 3.7
cache:
apt: true
directories:
- $HOME/.cache/pip
- ${BLENDER_CACHE}
# TODO: uncomment this section once we're ready to do proper unit tests
#addons:
# apt:
# packages:
# - blender
# This job is run any time there's an update to a branch (like when a commit is pushed or a PR is merged)
# and when a PR is created. But only for these branches
# You can enable/disable jobs for branch updates and/or PR creation in the settings for Stop-motion-OBJ on travis-ci.com
branches:
only:
- master
- /^version-.*$/ # TODO: remove this in the future. It's only there to support the "version-3" branch
- dev # TODO: create and use a "dev" branch for staging
before_install:
- export VERSION_TAG=`cat src/version.py | grep currentScriptVersion | head -1 | awk -F= '{ print $2 }' | sed 's/[\",()]//g' | awk '{printf "v%s.%s.%s", $1, $2, $3; if(NF >= 4) print "." $4}'`
# attempt to create a git tag for this version. If it fails, it means you may have forgotten to update the version number
# if it succeeds, we won't actually push the tag here; we just wanted to see whether it was already there
- git fetch --tags
- git tag $VERSION_TAG
- mkdir -p ${BLENDER_CACHE}
- ls ${BLENDER_CACHE}
# TODO: uncomment this section once we're ready to do proper unit tests
# install:
# - cd $TRAVIS_BUILD_DIR
# - python3 --version
# - pip install -r blender_requirements.txt
# - pip list
script:
- pytest
before_deploy:
# $TRAVIS_BUILD_DIR is the directory where the repo is cloned. You can treat it as the root folder of the repository
- cd $TRAVIS_BUILD_DIR
# extract the version number from version.py and massage it into the correct format
# also store it in $TRAVIS_TAG, which will later populate the git tag when we create a release
# https://www.geeksforgeeks.org/awk-command-unixlinux-examples/
- export TRAVIS_TAG=`cat src/version.py | grep currentScriptVersion | head -1 | awk -F= '{ print $2 }' | sed 's/[\",()]//g' | awk '{printf "v%s.%s.%s", $1, $2, $3; if(NF >= 4) print "." $4}'`
# if we have Travis create only draft releases, we probably don't need to automatically create git tags since the GitHub release page creates a tag when we publish a release
# - git tag $TRAVIS_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
# - git push origin --tags
# make sure this temporary folder doesn't already exist
- rm -rf Stop-motion-OBJ
- mkdir Stop-motion-OBJ
# copy all the source files to a temporary folder
- cp src/*.py README.md LICENSE Stop-motion-OBJ
# create the file name for the distributable
- export RELEASE_ZIP=${TRAVIS_BUILD_DIR}/Stop-motion-OBJ-${TRAVIS_TAG}.zip
# zip up the temporary folder with all of its contents (the -r is very important!)
- zip -r $RELEASE_ZIP Stop-motion-OBJ
deploy:
# Master branch
- provider: releases # 'releases' refers to GitHub Releases
prerelease: false # this is the real deal, not a pre-release
token: $GITHUB_PERSONAL_ACCESS_TOKEN # this variable is a secret key and is stored in the project settings for Stop Motion OBJ on travis-ci.com
file: $RELEASE_ZIP
name: $TRAVIS_TAG
skip_cleanup: true # make sure the .zip file doesn't get deleted before it gets published
draft: true # don't automatically publish the release. We need a chance to screen it and/or add release notes
on:
all_branches: true # run this deploy phase for every branch
condition: $TRAVIS_BRANCH =~ ^master$ # psych! Only for branches named "master"
# "version-X.X" and "dev" branches
- provider: releases
prerelease: true # this is just a pre-release
token: $GITHUB_PERSONAL_ACCESS_TOKEN
file: $RELEASE_ZIP
name: $TRAVIS_TAG
skip_cleanup: true
draft: true
on:
all_branches: true # also run this deploy phase for every branch
condition: $TRAVIS_BRANCH =~ (^version-.*$|^dev$) # gotcha again! This only runs for "dev" and "version-X" branches