Skip to content

Commit

Permalink
Merge pull request #57 from mono0926/automate-release
Browse files Browse the repository at this point in the history
Automate release
  • Loading branch information
mono0926 authored May 25, 2017
2 parents d9794c4 + be8e039 commit c3ffb75
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/LicensePlistCore/Consts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public struct Consts {
public static let prefix = "com.mono0926.LicensePlist"
public static let outputPath = "\(prefix).Output"
public static let configPath = "license_plist.yml"
public static let version = "1.4.3"
public static let version = "1.4.5"
public static let encoding = String.Encoding.utf8
}
2 changes: 1 addition & 1 deletion Tests/LicensePlistTests/Entity/PlistInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PlistInfoTests: XCTestCase {
target.compareWithLatestSummary()

XCTAssertEqual(target.summary,
"add-version-numbers: false\n\nLicensePlist Version: 1.4.1")
"add-version-numbers: false\n\nLicensePlist Version: 1.4.5")
XCTAssertNotNil(target.summaryPath)
}

Expand Down
12 changes: 12 additions & 0 deletions formula.rb.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class LicensePlist < Formula
desc "A license list generator of all your dependencies for iOS applications"
homepage ""
url "https://github.com/mono0926/LicensePlist/archive/{{TAG}}.tar.gz"
sha256 "{{SHA256}}"

def install
system "make", "install", "PREFIX=#{prefix}"
end

depends_on :xcode => ["8.3", :build]
end
58 changes: 58 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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}'"

# 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

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\"
}"

brew upgrade $lib_name
zip $lib_name.zip /usr/local/bin/$lib_name

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

0 comments on commit c3ffb75

Please sign in to comment.