Skip to content

Commit

Permalink
Merge pull request #81 from xmtp/nmolnar/fix-github-install
Browse files Browse the repository at this point in the history
Fix installation via GitHub
  • Loading branch information
neekolas authored Mar 2, 2022
2 parents ca85e98 + 3077fb3 commit bba3b3c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- uses: bufbuild/[email protected]
- name: Setup buf build
uses: bufbuild/[email protected]
- run: npm ci
- run: npm run build
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Setup buf build
uses: bufbuild/[email protected]
- run: npm ci
- run: npm run lint
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Setup buf build
uses: bufbuild/[email protected]
- run: npm ci
- run: npm run test:${{ matrix.env }}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"umd:main": "dist/umd/src/index.js",
"types": "dist/types/src/index.d.js",
"scripts": {
"prepublishOnly": "npm run build",
"build": "npm run build:proto && npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types",
"build:proto": "npm run clean:proto && buf generate",
"build:cjs": "node tools/cleanup cjs && tsc -p config/tsconfig.cjs.json",
Expand All @@ -17,7 +16,9 @@
"build:docs": "rm -rf docs && mkdir -p tmp && cp README.md tmp/ && sed -i.bak '/badge.svg/d' tmp/README.md && typedoc --excludePrivate --readme tmp/README.md src/index.ts",
"clean": "node tools/cleanup && npm run clean:proto",
"clean:proto": "rm -rf src/proto/*.ts",
"package": "npm run build && npm pack",
"package": "npm pack",
"prepare": "npm run install:buf && npm run build",
"install:buf": "./script/buf.sh || true",
"test": "npm run test:node",
"test:node": "jest --no-cache --runInBand --env='node'",
"test:jsdom": "jest --no-cache --runInBand --env='./jest.jsdom.env.js'",
Expand Down
22 changes: 22 additions & 0 deletions script/buf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Based loosely off of the script here https://docs.buf.build/ci-cd/setup
# Fixed a bug in their script + added support for checking if buf is already installed

set -eu

if which buf &>/dev/null; then
echo "Existing buf version found. No need to install"
exit 0
fi


# Use your desired buf version
BUF_VERSION=1.0.0
# Putting this in a location likely to already be in the $PATH
BIN_DIR="$npm_config_prefix/bin"

URL="https://github.com/bufbuild/buf/releases/download/v$BUF_VERSION/buf-$(uname -s)-$(uname -m)"
echo "Downloading buf from $URL"

curl -sSL $URL -o "$BIN_DIR/buf"
chmod +x "$BIN_DIR/buf"

0 comments on commit bba3b3c

Please sign in to comment.