-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bindu, Venki | BAH-1183 | Add github action for bahmni mart github re…
…lease (#36) * Bindu, Venki | BAH-1183 | Add github action for bahmni mart github release * Bindu | Add NOTICE file
- Loading branch information
Showing
4 changed files
with
141 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [2.7] | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_PASSWORD: password | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
|
||
mysql: | ||
image: mysql:5.6 | ||
env: | ||
MYSQL_ROOT_PASSWORD: password | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Create test_openmrs mysql database | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y mysql-client | ||
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "SHOW DATABASES" | ||
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "create database test_openmrs;" | ||
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "CREATE USER 'test_user'@'127.0.0.1' IDENTIFIED BY 'password';" | ||
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "GRANT ALL PRIVILEGES ON *.* TO 'test_user'@'%' IDENTIFIED by 'password';" | ||
mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "FLUSH PRIVILEGES;" | ||
- name: Create test_analytics postgres database | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install --yes --no-install-recommends postgresql-client | ||
- run: | | ||
PGPASSWORD=password psql -h 127.0.0.1 --port 5432 -U postgres -c "CREATE USER test_user WITH PASSWORD 'password' NOCREATEROLE SUPERUSER;" | ||
PGPASSWORD=password psql -h 127.0.0.1 --port 5432 -U postgres -c "CREATE DATABASE test_analytics WITH OWNER test_user;" | ||
PGPASSWORD=password psql -h 127.0.0.1 --port 5432 -U test_user test_analytics -c "CREATE SCHEMA bahmni_mart_scdf;" | ||
- name: chckout code | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
- run: ./scripts/travis/compile.sh | ||
- run: ./scripts/travis/test.sh | ||
- run: ./scripts/travis/createRpm.sh | ||
- shell: bash | ||
env: | ||
TOKEN: ${{ secrets.GH_TOKEN }} | ||
run: | | ||
./scripts/github-release.sh bahmni "$TOKEN" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Copyright (C) 2018 OpenMRS, Inc | ||
|
||
This product includes software developed under the stewardship of the Bahmni Coalition, under fiscal sponsorship of OpenMRS, Inc. (http://www.openmrs.org/) | ||
|
||
This product includes software developed at ThoughtWorks, Inc (http://www.thoughtworks.com/) |
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,58 @@ | ||
#!/bin/bash | ||
|
||
read_version(){ | ||
set -e; | ||
local version=$(awk '/^version/{print $NF}' build.gradle | tr -d \'); | ||
echo $version | ||
} | ||
|
||
create_release() { | ||
local token="$1"; | ||
local tag_name="$2"; | ||
local commit_sha="$3"; | ||
local repo_owner="$4"; | ||
|
||
curl -s -S -X POST "https://api.github.com/repos/$repo_owner/bahmni-mart/releases" \ | ||
-H "Authorization: token $token" \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"tag_name": "'"$tag_name"'", "name" : "'"$tag_name"'", "target_commitish":"'"$commit_sha"'" }'; | ||
} | ||
|
||
upload_asset() { | ||
set -e; | ||
|
||
local token="$1"; | ||
local name="$2"; | ||
local file="$3"; | ||
local id="$4"; | ||
local repo_owner="$5"; | ||
|
||
curl -s -S -X POST "https://uploads.github.com/repos/$repo_owner/bahmni-mart/releases/$id/assets?name=$name" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token $token" \ | ||
-H "Content-Type: application/x-rpm" \ | ||
--data-binary @"$file"; | ||
} | ||
|
||
main(){ | ||
# Assign global variables to local variables | ||
local repo_owner=${args[0]} | ||
local token=${args[1]}; | ||
local release_name=$(read_version) | ||
local name="bahmni-mart-${release_name}.noarch.rpm"; | ||
local file="$(pwd)/build/distributions/$name"; | ||
local commit_sha=$(git rev-parse HEAD) | ||
|
||
CREATE_RESPONSE=$(create_release "$token" "$release_name" "$commit_sha" "$repo_owner"); | ||
local release_id=$(echo $CREATE_RESPONSE | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]'); | ||
echo "Created a release with id $release_id" | ||
echo "Created Response ******************************" | ||
echo $CREATE_RESPONSE | ||
|
||
# #Upload asset and save the output from curl | ||
UPLOAD_RESPONSE=$(upload_asset "$token" "$name" "$file" "$release_id" "$repo_owner"); | ||
echo "Upload Response ******************************" | ||
echo "$UPLOAD_RESPONSE" | ||
} | ||
args=("$@") | ||
main |