-
-
Notifications
You must be signed in to change notification settings - Fork 146
/
release.sh
executable file
·101 lines (84 loc) · 2.35 KB
/
release.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
# Check arguments
if [ $# -eq 1 ]; then
echo "A tag and token argument is needed!(ex: ./release.sh 1.2.3 xxxxxxx)"
exit 1
fi
lib_name="license-plist"
tag=$1
token=$2
export GITHUB_TOKEN=$token
echo "Tag: '${tag}'"
echo "Token: '${token}'"
filename="${tag}.tar.gz"
echo "Filename: '${filename}'"
# build
make build
zip -j $lib_name.zip ./.build/release/$lib_name
# Prepare artifact bundle
binary_artifact="LicensePlistBinary-macos.artifactbundle.zip"
make spm_artifactbundle_macos
./Tools/update-artifact-bundle.sh "${tag}"
# Push updated binary target definition
git add Package.swift
git commit -m "release ${tag}"
git push origin HEAD
# Push tag
git tag $tag
git push origin $tag
curl -LOk "https://github.com/mono0926/LicensePlist/archive/${filename}"
sha256=$(shasum -a 256 $filename | cut -d ' ' -f 1)
rm $filename
# Homebrew
formula_path="$lib_name.rb"
formula_url="https://api.github.com/repos/mono0926/homebrew-$lib_name/contents/$formula_path"
sha=`curl GET $formula_url \
| jq -r '.sha'`
echo "sha: \n$sha"
content_encoded=`cat formula.rb.tmpl | sed -e "s/{{TAG}}/$tag/" | sed -e "s/{{SHA256}}/$sha256/" | openssl enc -e -base64 | tr -d '\n '`
echo "content_encoded: \n$content_encoded"
commit_message="Update version to $tag"
curl -i -X PUT $formula_url \
-H "Content-Type:application/json" \
-H "Authorization:token $token" \
-d \
"{
\"path\":\"$formula_path\",
\"sha\":\"$sha\",
\"content\":\"$content_encoded\",
\"message\":\"$commit_message\"
}"
# GitHub Release
github-release release \
--user mono0926 \
--repo LicensePlist \
--tag $tag
github-release upload \
--user mono0926 \
--repo LicensePlist \
--tag $tag \
--name "$lib_name.zip" \
--file $lib_name.zip
rm $lib_name.zip
# Upload artifact bundle
github-release upload \
--user mono0926 \
--repo LicensePlist \
--tag $tag \
--name $binary_artifact \
--file $binary_artifact
rm $binary_artifact
# CocoaPods
make portable_zip
portable_zip_name="portable_licenseplist.zip"
github-release upload \
--user mono0926 \
--repo LicensePlist \
--tag $tag \
--name "$portable_zip_name" \
--file $portable_zip_name
rm $portable_zip_name
podspec_name="LicensePlist.podspec"
cat "$podspec_name.tmp" | sed s/LATEST_RELEASE_VERSION_NUMBER/$tag/ > "$podspec_name"
pod trunk push $podspec_name --allow-warnings
rm $podspec_name