Skip to content

Commit

Permalink
Release Windows to Github (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
achew22 authored Mar 17, 2019
1 parent 52c95f5 commit 96521c3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
9 changes: 6 additions & 3 deletions release/github/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ compile() {
export GOOS=$1; shift
export GOARCH=$1; shift

DESTINATION="${STAGING}/ibazel_${GOOS}_${GOARCH}"
EXTENSION=""
if [[ "${GOOS}" == "windows" ]]; then
DESTINATION="${DESTINATION}.exe"
EXTENSION=".exe"
fi
DESTINATION="${STAGING}/ibazel_${GOOS}_${GOARCH}${EXTENSION}"
bazel build \
--config=release \
"--experimental_platforms=@io_bazel_rules_go//go/toolchain:${GOOS}_${GOARCH}" \
"//ibazel:ibazel"
SOURCE="$(bazel info bazel-bin)/ibazel/${GOOS}_${GOARCH}_pure_stripped/ibazel"
SOURCE="$(bazel info bazel-bin)/ibazel/${GOOS}_${GOARCH}_pure_stripped/ibazel${EXTENSION}"
cp "${SOURCE}" "${DESTINATION}"

# Sometimes bazel likes to change the ouput directory for binaries
Expand All @@ -62,4 +63,6 @@ echo "Build successful."
readonly GHR_BINARY="$(mktemp /tmp/ghr.XXXXXX)"
go get -u github.com/tcnksm/ghr
go build -o "${GHR_BINARY}" github.com/tcnksm/ghr
echo -n "Publishing ${STAGING} to GitHub as ${TAG}"
"${GHR_BINARY}" -t "${CHANGELOG_GITHUB_TOKEN}" "${TAG}" "${STAGING}"
find "${STAGING}"
25 changes: 17 additions & 8 deletions release/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ const spawn = require('child_process').spawn;

function main(args) {
const arch = {
'x64': 'amd64',
'x64' : 'amd64',
}[os.arch()];
// Filter the platform based on the platforms that are build/included.
const platform = {
'darwin': 'darwin',
'linux': 'linux',
'windows': 'windows',
'darwin' : 'darwin',
'linux' : 'linux',
'windows' : 'windows',
}[os.platform()];
const extension = {
'darwin' : '',
'linux' : '',
'windows' : '.exe',
}[os.platform()];

if (arch == undefined || platform == undefined) {
Expand All @@ -47,10 +52,13 @@ function main(args) {

// Walk up the cwd, looking for a local ibazel installation
for (var i = dirs.length; i > 0; i--) {
var attemptedBasePath = [...dirs.slice(0, i), 'node_modules', '@bazel', 'ibazel'].join(path.sep);
var attemptedBasePath =
[...dirs.slice(0, i), 'node_modules', '@bazel', 'ibazel' ].join(
path.sep);

// If we find a local installation, use that one instead
if (fs.existsSync(path.join(attemptedBasePath, 'bin', `${platform}_${arch}`, 'ibazel'))) {
if (fs.existsSync(path.join(attemptedBasePath, 'bin', `${platform}_${arch}`,
'ibazel' + extension))) {
basePath = attemptedBasePath;
foundLocalInstallation = true;
break;
Expand All @@ -64,8 +72,9 @@ function main(args) {
Using the globally installed version at ${__dirname}`);
}

const binary = path.join(basePath, 'bin', `${platform}_${arch}`, 'ibazel');
const ibazel = spawn(binary, args, {stdio: 'inherit'});
const binary =
path.join(basePath, 'bin', `${platform}_${arch}`, 'ibazel' + extension);
const ibazel = spawn(binary, args, {stdio : 'inherit'});

function shutdown() {
ibazel.kill("SIGTERM")
Expand Down
9 changes: 5 additions & 4 deletions release/npm/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ compile() {
export GOARCH=$1; shift

mkdir -p "${STAGING}/bin/${GOOS}_${GOARCH}/"
DESTINATION="${STAGING}/bin/${GOOS}_${GOARCH}/ibazel"
EXTENSION=""
if [[ "${GOOS}" == "windows" ]]; then
DESTINATION="${DESTINATION}.exe"
EXTENSION=".exe"
fi
DESTINATION="${STAGING}/bin/${GOOS}_${GOARCH}/ibazel${EXTENSION}"
bazel build \
--config=release \
"--experimental_platforms=@io_bazel_rules_go//go/toolchain:${GOOS}_${GOARCH}" \
"//ibazel:ibazel"
SOURCE="$(bazel info bazel-bin)/ibazel/${GOOS}_${GOARCH}_pure_stripped/ibazel"
SOURCE="$(bazel info bazel-bin)/ibazel/${GOOS}_${GOARCH}_pure_stripped/ibazel${EXTENSION}"
cp "${SOURCE}" "${DESTINATION}"

# Sometimes bazel likes to change the ouput directory for binaries
Expand All @@ -66,4 +67,4 @@ echo -n "Publishing ${STAGING} to NPM as "
grep "version" < "${STAGING}/package.json"

# Everything is staged now, actually upload the package.
cd "$STAGING" && npm publish
cd "$STAGING" && find . && npm publish

0 comments on commit 96521c3

Please sign in to comment.