Skip to content

Commit 33ac876

Browse files
author
Phrase
committed
Deploying from phrase/openapi@97fc6a90
1 parent 9aec7e4 commit 33ac876

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
## Specific to RubyMotion:
1717
.dat*
1818
.repl_history
19-
build/
2019

2120
## Documentation cache and generated files:
2221
/.yardoc/

build/release_github_package.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
echo "Build release $VERSION"
6+
7+
echo "Setting up gem version"
8+
sed -e "s/1.0.0/${VERSION}/g" ./version.rb.template > ./lib/phrase/version.rb
9+
rm ./version.rb.template
10+
11+
[ -z "${GITHUB_TOKEN}" ] && { echo "Missing input.token!"; exit 2; }
12+
[ -z "${OWNER}" ] && { echo "Missing input.owner!"; exit 2; }
13+
14+
echo "Setting up access to GitHub Package Registry"
15+
mkdir -p ~/.gem
16+
touch ~/.gem/credentials
17+
chmod 600 ~/.gem/credentials
18+
echo ":github: Bearer ${GITHUB_TOKEN}" >> ~/.gem/credentials
19+
20+
echo "Building the gem"
21+
gem build *.gemspec
22+
23+
echo "Pushing the built gem to GitHub Package Registry"
24+
gem push --key github --host "https://rubygems.pkg.github.com/${OWNER}" *.gem
25+
26+
# Create release
27+
function create_release_data()
28+
{
29+
cat <<EOF
30+
{
31+
"tag_name": "${VERSION}",
32+
"name": "${VERSION}",
33+
"draft": true,
34+
"prerelease": false
35+
}
36+
EOF
37+
}
38+
39+
echo "Create release $VERSION"
40+
api_url="https://api.github.com/repos/phrase/phrase-ruby/releases?access_token=${GITHUB_TOKEN}"
41+
response="$(curl --data "$(create_release_data)" ${api_url})"
42+
release_id=$(echo $response | python -c "import sys, json; print json.load(sys.stdin)['id']")
43+
44+
if [ -z "$release_id" ]
45+
then
46+
echo "Failed to create GitHub release"
47+
echo $response
48+
exit 1
49+
else
50+
echo "New release created created with id: ${release_id}"
51+
fi
52+
53+
# Upload artifacts
54+
DIST_DIR="."
55+
for file in "$DIST_DIR"/*.gem; do
56+
echo "Uploading ${file}"
57+
asset="https://uploads.github.com/repos/phrase/phrase-ruby/releases/${release_id}/assets?name=$(basename "$file")&access_token=${GITHUB_TOKEN}"
58+
curl --data-binary @"$file" -H "Content-Type: application/octet-stream" $asset > /dev/null
59+
echo Hash: $(sha256sum $file)
60+
done
61+
62+
echo "Release successful"

0 commit comments

Comments
 (0)