-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#56: Auto-deploy to github releases from travis, appveyor and circleci
- Loading branch information
Showing
5 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
version: 2 | ||
|
||
jobs: | ||
test: | ||
working_directory: ~/tgst | ||
build: | ||
docker: | ||
- image: tomaka/cargo-apk | ||
steps: | ||
- checkout | ||
- run: cargo apk build | ||
|
||
deploy: | ||
docker: | ||
- image: tomaka/cargo-apk | ||
steps: | ||
- checkout | ||
- run: git clone --depth=1 https://github.com/ozkriff/zemeroth_assets assets | ||
- run: cargo apk build | ||
- run: ./.circleci/upload_apk_to_github_releases.sh | ||
|
||
workflows: | ||
version: 2 | ||
build-test-and-deploy: | ||
build-and-deploy: | ||
jobs: | ||
- test | ||
- build: | ||
filters: | ||
tags: | ||
ignore: /.*/ | ||
- deploy: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
ignore: /.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
# Based on https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 | ||
|
||
# https://github.com/settings/tokens -> circleci's env GITHUB_API_TOKEN | ||
|
||
set -e | ||
|
||
tag=$CIRCLE_TAG | ||
owner=$CIRCLE_PROJECT_USERNAME | ||
repo=$CIRCLE_PROJECT_REPONAME | ||
filename=./zemeroth-debug.apk | ||
GH_REPO="https://api.github.com/repos/$owner/$repo" | ||
GH_TAGS="$GH_REPO/releases/tags/$tag" | ||
AUTH="Authorization: token $GITHUB_API_TOKEN" | ||
|
||
cp ./target/android-artifacts/app/build/outputs/apk/app-debug.apk $filename | ||
|
||
# Validate token. | ||
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; } | ||
|
||
# Create a release | ||
RELEASE_URL="https://api.github.com/repos/$owner/$repo/releases?access_token=$GITHUB_API_TOKEN" | ||
curl --data "{\"tag_name\": \"$tag\"}" $RELEASE_URL | ||
|
||
# Read asset tags | ||
response=$(curl -sH "$AUTH" $GH_TAGS) | ||
|
||
# Get ID of the asset based on given filename | ||
eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=') | ||
[ "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response\n" >&2; exit 1; } | ||
|
||
# Upload the asset | ||
GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$(basename $filename)" | ||
curl --data-binary @"$filename" -H "$AUTH" -H "Content-Type: application/octet-stream" $GH_ASSET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters