-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwercker.yml
78 lines (70 loc) · 5.65 KB
/
wercker.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
box: floydpink/ubuntu-install-builder
build:
steps:
- script:
name: create a release, tag and push the installers to the website
code: |-
DEPLOY_READY_BRANCH=$(head -n 1 branch)
VERSION=`echo ${DEPLOY_READY_BRANCH} | cut -d'-' -f 2`
BARE_VERSION=`echo ${VERSION} | cut -c 2-`
SOURCE_BRANCH="source"
WEBSITE_REPO="https://github.com/flickr-downloadr/flickr-downloadr.github.io.git"
echo "0. Install zip and unzip"
sudo apt-get update
sudo apt-get install zip unzip -y
echo "1. Create a new release on GitHub using the tag created from the Mac CI build (Travis CI)"
echo "1.1 Downloading jq"
wget "http://stedolan.github.io/jq/download/linux64/jq"
chmod +x jq
echo "1.2 Cloning the website repo"
mkdir ${VERSION}
mkdir installerRepo && cd $_
git clone $WEBSITE_REPO
cd flickr-downloadr.github.io
git config credential.helper "store --file=.git/fd-credentials"
echo "https://${GH_TOKEN}:@github.com" > .git/fd-credentials
git config push.default tracking
git checkout $DEPLOY_READY_BRANCH
PREVIOUS_VERSION=$(head -n 1 app/build.number)
echo "1.3 Copying the new installers to a separate directory"
cp -r ./app/installer/* ../../${VERSION}
cd ../..
echo "1.4 Deleting the git directory, dependecies and previous version installers"
rm -rf ${VERSION}/**/.git* ${VERSION}/**/dependencies
rm ${VERSION}/linux/flickrdownloadr-${PREVIOUS_VERSION}-linux-installer.run ${VERSION}/linux-x64/flickrdownloadr-${PREVIOUS_VERSION}-0.x86_64.rpm ${VERSION}/linux-x64/flickrdownloadr-${PREVIOUS_VERSION}-linux-x64-installer.run ${VERSION}/linux-x64/flickrdownloadr_${PREVIOUS_VERSION}-0_amd64.deb "${VERSION}/osx/Install flickr downloadr (v${PREVIOUS_VERSION}).dmg" ${VERSION}/windows/flickrdownloadr-${PREVIOUS_VERSION}-windows-installer.exe
cd ${VERSION}
echo "1.5 Zipping the release assets"
zip -r linux-x64.zip ./linux-x64
zip -r linux.zip ./linux
zip -r osx.zip ./osx
zip -r windows.zip ./windows
echo "1.6 Creating the release"
RELEASE_JSON_PAYLOAD=$(printf '{ "tag_name": "%s", "name": "%s" }' $VERSION $VERSION)
echo "RELEASE_JSON_PAYLOAD: ${RELEASE_JSON_PAYLOAD}"
echo "1.7 Uploading the release assets"
UPLOAD_URL=$(curl --user ${GH_TOKEN}:x-oauth-basic --request POST --data "${RELEASE_JSON_PAYLOAD}" https://api.github.com/repos/flickr-downloadr/flickr-downloadr-gtk/releases | ../jq -r '.upload_url')
echo "UPLOAD_URL: ${UPLOAD_URL}"
if [[ ${UPLOAD_URL} != */assets{?name,label} ]]; then exit 100; fi
UPLOAD_URL_WITH_NAME=$(echo $UPLOAD_URL | sed 's/{?name,label}$/\?name=/')
curl --request POST --user ${GH_TOKEN}:x-oauth-basic --header "Content-Type:application/zip" --data-binary @linux-x64.zip "${UPLOAD_URL_WITH_NAME}linux-x64.zip"
curl --request POST --user ${GH_TOKEN}:x-oauth-basic --header "Content-Type:application/zip" --data-binary @linux.zip "${UPLOAD_URL_WITH_NAME}linux.zip"
curl --request POST --user ${GH_TOKEN}:x-oauth-basic --header "Content-Type:application/zip" --data-binary @osx.zip "${UPLOAD_URL_WITH_NAME}osx.zip"
curl --request POST --user ${GH_TOKEN}:x-oauth-basic --header "Content-Type:application/zip" --data-binary @windows.zip "${UPLOAD_URL_WITH_NAME}windows.zip"
echo "2. Delete previous installers on fd.github.io/${SOURCE_BRANCH}"
cd ../installerRepo/flickr-downloadr.github.io
git checkout $SOURCE_BRANCH
git rm --ignore-unmatch app/installer/linux/flickrdownloadr-${PREVIOUS_VERSION}-linux-installer.run app/installer/linux-x64/flickrdownloadr-${PREVIOUS_VERSION}-0.x86_64.rpm app/installer/linux-x64/flickrdownloadr-${PREVIOUS_VERSION}-linux-x64-installer.run app/installer/linux-x64/flickrdownloadr_${PREVIOUS_VERSION}-0_amd64.deb "app/installer/osx/Install flickr downloadr (v${PREVIOUS_VERSION}).dmg" app/installer/windows/flickrdownloadr-${PREVIOUS_VERSION}-windows-installer.exe
echo "3. Add current installers to fd.github.io/${SOURCE_BRANCH}"
cp -r ../../${VERSION}/* ./app/installer
git add app/installer/linux/flickrdownloadr-${BARE_VERSION}-linux-installer.run app/installer/linux-x64/flickrdownloadr-${BARE_VERSION}-0.x86_64.rpm app/installer/linux-x64/flickrdownloadr-${BARE_VERSION}-linux-x64-installer.run app/installer/linux-x64/flickrdownloadr_${BARE_VERSION}-0_amd64.deb "app/installer/osx/Install flickr downloadr (v${BARE_VERSION}).dmg" app/installer/windows/flickrdownloadr-${BARE_VERSION}-windows-installer.exe
echo "4. Update build.number file to the latest version on fd.github.io/${SOURCE_BRANCH}"
echo -n $BARE_VERSION > app/build.number
echo "5. Commit and push all changes to GitHub"
git config --global user.name "The CI Bot"
git config --global user.email "contact.us@flickrdownloadr.com"
git commit -asm "Published version ${VERSION} to the website"
git push origin $SOURCE_BRANCH
echo "6. Delete the deploy branch on GitHub"
git push origin :$DEPLOY_READY_BRANCH
echo "7. Just keep the build.number file alone for the output directory"
cp app/build.number "${WERCKER_OUTPUT_DIR}/"