-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
76 lines (69 loc) · 2.97 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
##############################################################################################
#
# Travis CI configuration file
#
# Set the required secrets in the build settings of the project:
# - BINTRAY_USER
# - BINTRAY_API_KEY
#
##############################################################################################
env:
global:
- PACKAGE_NAME=rpm-builder-bintray
- PACKAGE_DESC="Builder tool to create .rpm packages (using Travis) and upload to Bintray"
- BINTRAY_REPO_NAME=rpm
- BINTRAY_LICENSE=LGPL-2.1
- TARGET_ARCH=noarch
addons:
apt:
packages:
- rpm
before_install:
# Export variables containing versions and filename
- export SOFTWARE_VERSION=$(cat VERSION)
- export RELEASE_VERSION=$TRAVIS_BUILD_NUMBER
- export BUILD_VERSION=$SOFTWARE_VERSION.$RELEASE_VERSION
- export BUILD_DATE=$(date "+%Y%m%d")
- export PACKAGE_NAME_VERSION=$PACKAGE_NAME-$SOFTWARE_VERSION-$RELEASE_VERSION.$TARGET_ARCH.rpm
script:
# Replace version and build number with the RPM .spec file
- sed -i "s/__NAME__/$PACKAGE_NAME/g" $PACKAGE_NAME/*.spec
- sed -i "s/__DESC__/$PACKAGE_DESC/g" $PACKAGE_NAME/*.spec
- sed -i "s/__LICENSE__/$BINTRAY_LICENSE/g" $PACKAGE_NAME/*.spec
- sed -i "s/__SOFTWARE_VERSION__/$SOFTWARE_VERSION/g" $PACKAGE_NAME/*.spec
- sed -i "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" $PACKAGE_NAME/*.spec
- sed -i "s/__DATE__/$BUILD_DATE/g" $PACKAGE_NAME/*.spec
# Create the RPM package
- cd $PACKAGE_NAME
- mkdir -p ./{BUILD,RPMS,SOURCES,SPECS,SRPMS}
- cp -r files/ BUILD
- rpmbuild -v -bb --target $TARGET_ARCH --define "_topdir `pwd`" --define "package_files `pwd`/BUILD/files" rpm.spec
- cd ..
after_success:
# Output detail on the resulting package for debugging purpose
- rpm -qlpv $PACKAGE_NAME/RPMS/$TARGET_ARCH/$PACKAGE_NAME_VERSION
- md5sum $PACKAGE_NAME/RPMS/$TARGET_ARCH/$PACKAGE_NAME_VERSION
- sha256sum $PACKAGE_NAME/RPMS/$TARGET_ARCH/$PACKAGE_NAME_VERSION
- export LOCAL_SHA256=$( sha256sum $PACKAGE_NAME/RPMS/$TARGET_ARCH/$PACKAGE_NAME_VERSION | cut -d " " -f1 )
before_deploy:
# Set the packages name and details in the descriptor file
- sed -i "s/__NAME__/$PACKAGE_NAME/g" bintray-descriptor.json
- sed -i "s/__REPO_NAME__/$BINTRAY_REPO_NAME/g" bintray-descriptor.json
- sed -i "s/__SUBJECT__/$BINTRAY_USER/g" bintray-descriptor.json
- sed -i "s/__LICENSE__/$BINTRAY_LICENSE/g" bintray-descriptor.json
- sed -i "s/__VERSION__/$BUILD_VERSION/g" bintray-descriptor.json
deploy:
# Upload RPM packages to Bintray
provider: bintray
file: bintray-descriptor.json
user: $BINTRAY_USER
key: $BINTRAY_API_KEY
skip_cleanup: true
after_deploy:
# Add time delay to let the servers process the uploaded files
- sleep 90
# Place link to the file in download list
- |
curl --silent --show-error --fail\
-X PUT -H "Content-Type: application/json" -d'{"list_in_downloads": true}'\
-u$BINTRAY_USER:$BINTRAY_API_KEY https://api.bintray.com/file_metadata/$BINTRAY_USER/$BINTRAY_REPO_NAME/$PACKAGE_NAME_VERSION