Skip to content

Commit 0d2d4df

Browse files
committed
#56: Auto-deploy to github releases from travis, appveyor and circleci
1 parent 426497e commit 0d2d4df

File tree

5 files changed

+106
-6
lines changed

5 files changed

+106
-6
lines changed

.circleci/config.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
version: 2
22

33
jobs:
4-
test:
5-
working_directory: ~/tgst
4+
build:
65
docker:
76
- image: tomaka/cargo-apk
87
steps:
98
- checkout
109
- run: cargo apk build
1110

11+
deploy:
12+
docker:
13+
- image: tomaka/cargo-apk
14+
steps:
15+
- checkout
16+
- run: git clone --depth=1 https://github.com/ozkriff/zemeroth_assets assets
17+
- run: cargo apk build
18+
- run: ./.circleci/upload_apk_to_github_releases.sh
19+
1220
workflows:
1321
version: 2
14-
build-test-and-deploy:
22+
build-and-deploy:
1523
jobs:
16-
- test
24+
- build:
25+
filters:
26+
tags:
27+
ignore: /.*/
28+
- deploy:
29+
filters:
30+
tags:
31+
only: /.*/
32+
branches:
33+
ignore: /.*/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
# Based on https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
4+
5+
# https://github.com/settings/tokens -> circleci's env GITHUB_API_TOKEN
6+
7+
set -e
8+
9+
tag=$CIRCLE_TAG
10+
owner=$CIRCLE_PROJECT_USERNAME
11+
repo=$CIRCLE_PROJECT_REPONAME
12+
filename=./zemeroth-debug.apk
13+
GH_REPO="https://api.github.com/repos/$owner/$repo"
14+
GH_TAGS="$GH_REPO/releases/tags/$tag"
15+
AUTH="Authorization: token $GITHUB_API_TOKEN"
16+
17+
cp ./target/android-artifacts/app/build/outputs/apk/app-debug.apk $filename
18+
19+
# Validate token.
20+
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; }
21+
22+
# Create a release
23+
RELEASE_URL="https://api.github.com/repos/$owner/$repo/releases?access_token=$GITHUB_API_TOKEN"
24+
curl --data "{\"tag_name\": \"$tag\"}" $RELEASE_URL
25+
26+
# Read asset tags
27+
response=$(curl -sH "$AUTH" $GH_TAGS)
28+
29+
# Get ID of the asset based on given filename
30+
eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
31+
[ "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response\n" >&2; exit 1; }
32+
33+
# Upload the asset
34+
GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$(basename $filename)"
35+
curl --data-binary @"$filename" -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET

.travis.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
language: rust
22

3+
env:
4+
- zipname="zemeroth-$TRAVIS_OS_NAME.tar.gz"
5+
36
cache: cargo
47

58
rust:
@@ -18,4 +21,21 @@ os:
1821
sudo: false
1922

2023
script:
21-
- cargo build && cargo test
24+
- cargo build
25+
- cargo test
26+
- cargo build --release
27+
28+
before_deploy:
29+
- git clone --depth=1 https://github.com/ozkriff/zemeroth_assets assets
30+
- mv target/release/zemeroth .
31+
- tar -zcvf $zipname assets zemeroth
32+
33+
deploy:
34+
provider: releases
35+
skip_cleanup: true
36+
overwrite: true
37+
file: $zipname
38+
api_key:
39+
secure: sn8NPGcybxiRAIDp5Tk5nhvg89PTgm75VjkyjYfufKmuk3KDOhW2b2CYC6VvlM88a4FAMSWDaYXKi0N3yEYFC2RmqrvtpocBGKsom2fSmvRv/4YWIWCOK7Zpw7IBhRfTn/2dHkLa3Uy+7dyO96LW8qtiuEsotyJCrWaXuLr1+wYdWXWL6oeGsw41sB22Umc4WZJP/SryjGb+5b349WNCipf0rMLdU0sqW7fOJfIg0cv9W1k9FiuHLfw3Li1JzU2qo5TWX3oxv8MPFQ9/lVEHAYkI8tvxaSheN/L3xlpWV1Qjrk9vxN1bIVygyCaARJhzTgTAZ+OH4B1h1Mkwc0emY6ITRbcN4khko599E17AvmhVrB7xE0wNtJtVS9z2coWqcC4MO1yLIFGyC8hxH6BubmGTQln1q7KRy48l8uNJczfW+vi6lwj8Sni0HungZZBzyfv6eNPzU0IZE6rh+FN2pmdfaqAxjo8BPfyZvJFuJqJcTNvUkdT9fXyILgHuzdEmQBOVZhzqn3jOJfv3kHpaEF7prywEEzRr0A4S1RvMCyYN9PH7XvcGKGq1dJNEwCHmgnUfuCkROBKBnsa9PvJTPy3tHY7Z0EhveoQYXMnfhlqN3LTBb3l6Gwg2GK1lajLuLB/Q6tGKuGgRI1r5sLwqPFioIjuL71LecnAgyMilm5c=
40+
on:
41+
tags: true

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ News: https://twitter.com/ozkriff
1414
Devlog album: http://imgur.com/a/SMVqO
1515

1616

17+
Downloads
18+
---------
19+
20+
Precompiled binaries for linux, win, osx and android: https://github.com/ozkriff/zemeroth/releases
21+
22+
1723
Overview
1824
--------
1925

appveyor.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
environment:
2+
global:
3+
PROJECT_NAME: zemeroth
24
matrix:
35
- TARGET: i686-pc-windows-gnu
46
CHANNEL: stable
@@ -28,8 +30,28 @@ install:
2830
build: false
2931

3032
test_script:
31-
- cmd: 'cargo build && cargo test'
33+
- cmd: 'cargo build && cargo test && cargo build --release'
3234

3335
cache:
3436
- target
3537
- C:\Users\appveyor\.cargo\registry
38+
39+
before_deploy:
40+
- mkdir staging
41+
- mkdir staging\assets
42+
- copy target\release\zemeroth.exe staging
43+
- cd staging
44+
- git clone --depth=1 https://github.com/ozkriff/zemeroth_assets assets
45+
- 7z a ../%PROJECT_NAME%-%TARGET%.zip *
46+
- appveyor PushArtifact ../%PROJECT_NAME%-%TARGET%.zip
47+
48+
deploy:
49+
provider: GitHub
50+
artifact: /.*\.zip/
51+
auth_token:
52+
secure: ENk8Tp+3wU90QF5utTGj5QM3bYyXHRtWm+mMgH+SotiCbIRc6mf0DsoKQgA1F/64
53+
on:
54+
CHANNEL: stable
55+
appveyor_repo_tag: true
56+
branch:
57+
- master

0 commit comments

Comments
 (0)