Skip to content

Commit a78c80a

Browse files
committed
ci: add test scripts
1 parent 16e42c0 commit a78c80a

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Change Log
2+
3+
# 0.0.2 (2022-11-01)
4+
5+
6+
### Bug fixes
7+
8+
* remove boolean case condition
9+
10+
# 0.0.1 (2022-10-13)
11+
12+
### Initial release

test-continuous-push.sh

Whitespace-only changes.

test-description.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version=" 0.0.2"
2+
formatted_version=$(echo "$version" | xargs)
3+
description=$(cat "CHANGELOG.md" | awk -v pattern="# ${formatted_version}" '$0 ~ pattern{flag=1;next}/# [0-9]/{flag=0}flag')
4+
formatted_description=$(echo "$description" | awk 'BEGIN{RS="\n";ORS="\\n"}1')
5+
6+
echo -e "$formatted_description"

test-script.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version="0.0.9"
2+
description="
3+
4+
5+
### Bug fixes
6+
7+
* update tests
8+
"
9+
new_description=$(echo "$description" | awk 'BEGIN{RS="\n";ORS="\\n"}1')
10+
echo -e "$new_description"
11+
12+
# Create and push tags
13+
git tag "${version}" master
14+
git push origin "${version}"
15+
16+
# Make github release
17+
github_account="Slava-Inyu"
18+
github_repo_name="test-github-release"
19+
github_auth_token="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"
20+
auth_header="Authorization: token ${github_auth_token}"
21+
22+
github_api="https://api.github.com/repos/${github_account}/${github_repo_name}"
23+
24+
function status_check {
25+
local status_code="${1}"
26+
27+
case "$status_code" in
28+
"401")
29+
echo "Error: Authentication token is not valid"
30+
exit 1
31+
;;
32+
"422")
33+
echo "Error: Couldn't create new relese - release already exists"
34+
exit 1
35+
;;
36+
"200")
37+
echo "Success: Token is valid"
38+
;;
39+
"201")
40+
echo "Success: Release was successfully created"
41+
;;
42+
*)
43+
echo "Error: Something went wrong while creating new release, status code ${status_code}"
44+
;;
45+
esac
46+
}
47+
48+
49+
# Validate token
50+
response_status=$(curl -sH "${auth_header}" -I "${github_api}" | awk -F " " 'NR==1{print $2}')
51+
status_check $response_status
52+
53+
# Create release
54+
github_api_release="${github_api}/releases"
55+
json_data="{\"tag_name\": \"$version\", \"name\": \"$github_repo_name\", \"body\": \"$new_description\" }"
56+
57+
response_status=$(curl -o /dev/null -sH "${auth_header}" --write-out '%{http_code}' --data "${json_data}" "${github_api_release}")
58+
status_check $response_status

0 commit comments

Comments
 (0)