Skip to content

Commit

Permalink
Distribute CLI binary with Homebrew (#61)
Browse files Browse the repository at this point in the history
Created a tap in [homebrew-tap](https://github.com/julioz/homebrew-tap) repo and add a release script to continuously update it, following kscripting/kscript#50
  • Loading branch information
julioz committed Dec 19, 2020
2 parents 7dfa435 + 54d9499 commit 2f20cde
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ fabric.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Homebrew setup
homebrew-tap/

### Gradle ###
.gradle
build/
Expand Down
7 changes: 7 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ git tag v<next-release-version>
git push origin v<next-release-version>
```

* Create a [new GitHub release based on that tag](https://github.com/julioz/FloorPlan/releases/new), and upload the zip and tar distributions

* Make sure you have valid credentials in `~/.gradle/gradle.properties` to upload the artifacts
```
SONATYPE_NEXUS_USERNAME=
Expand All @@ -108,6 +110,11 @@ SONATYPE_NEXUS_PASSWORD=
./gradlew publishPlugins
```

* Release via homebrew
```
scripts/release_homebrew.sh
```

* Merge the release branch to master
```
git checkout master
Expand Down
7 changes: 7 additions & 0 deletions docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ After checking out this repository, [make sure you have Gradle installed](https:
gradlew run --args="<path-to-schema-file>"
```

### Installation with Homebrew

On MacOS you can install `FloorPlan` also with [Homebrew](https://brew.sh/)
```
brew install julioz/tap/floorplan
```

## Command-line arguments

### Output format (`--format`, `-f`)
Expand Down
59 changes: 59 additions & 0 deletions scripts/release_homebrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
set -e
set -o pipefail

## Update the homebrew descriptor (Inspired by https://github.com/holgerbrandl/kscript/issues/50)

FLOORPLAN_CLI_HOME=floorplan-cli
FLOORPLAN_CLI_BINARY_NAME=floorplan-cli
floorplan_version=$(grep 'floorPlanVersion' versioning.gradle | cut -f2 -d'=' | tr -d ' "')
FLOORPLAN_DISTRIBUTION_NAME="${FLOORPLAN_CLI_BINARY_NAME}-${floorplan_version}"

echo "Ready to release FloorPlan $floorplan_version to Homebrew."
read -p "Do you wish to continue? " -n 1 -r
echo # move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi

ARCHIVE_DIR=cli-archive/

mkdir -p $ARCHIVE_DIR/
cp ${FLOORPLAN_CLI_HOME}/build/distributions/${FLOORPLAN_DISTRIBUTION_NAME}.zip $ARCHIVE_DIR/

if [ ! -f ${ARCHIVE_DIR}/${FLOORPLAN_DISTRIBUTION_NAME}.zip ]; then
echo "Distribution binary zip file not found!"
exit 1;
fi

archiveMd5=$(shasum -a 256 ${ARCHIVE_DIR}/${FLOORPLAN_DISTRIBUTION_NAME}.zip | cut -f1 -d ' ')

echo "MD5 SHA256 of zipped binary is $archiveMd5."

rm -rf homebrew-tap
git clone https://github.com/julioz/homebrew-tap.git
cd homebrew-tap

git config user.email "julioz@users.noreply.github.com"

cat - <<EOF > floorplan.rb
class Floorplan < Formula
desc "floorplan"
homepage "https://github.com/julioz/FloorPlan"
url "https://github.com/julioz/FloorPlan/releases/download/v${floorplan_version}/${FLOORPLAN_DISTRIBUTION_NAME}.zip"
sha256 "${archiveMd5}"
bottle :unneeded
depends_on "kotlin"
def install
libexec.install Dir["*"] # Put the extracted files in to the 'private' libexec folder
bin.install_symlink "#{libexec}/bin/floorplan-cli"
end
end
EOF

git add floorplan.rb
git commit -m "v${floorplan_version} release"
git push

## to test use `brew install julioz/tap/floorplan`

0 comments on commit 2f20cde

Please sign in to comment.