Skip to content

Commit

Permalink
Fix multiple machines issues (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Dolev Hadar <6196971+dlvhdr@users.noreply.github.com>
  • Loading branch information
abdfnx and dlvhdr authored Nov 25, 2021
1 parent b8e9ae5 commit ae6d757
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
name: release
name: Release

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release:
description: "The New Release"
required: true

env:
RELEASE: ${{ github.event.inputs.release }}
GITHUB_TOKEN: ${{ github.token }}

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: cli/gh-extension-precompile@v1

- name: Setup Go
uses: actions/setup-go@v2.1.4
with:
go-version: "1.17.3"

- name: Release
run: |
sudo chmod 755 ./release.sh
./release.sh ${{ env.RELEASE }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
debug.log
dist
55 changes: 55 additions & 0 deletions gh-prs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
set -e

repo="dlvhdr/gh-prs"

extensionPath="$(dirname "$0")"
arch="$(uname -m)"

exe=""

if uname -a | grep Msys > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="windows-x86_64"
elif [ $arch = "i686" ]; then
exe="windows-i386"
elif [ $arch = "i386" ]; then
exe="windows-i386"
fi
elif uname -a | grep Darwin > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="darwin-x86_64"
elif [ $arch = "arm64" ]; then
exe="darwin-arm64"
fi
elif uname -a | grep Linux > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="linux-x86_64"
elif [ $arch = "i686" ]; then
exe="linux-i386"
elif [ $arch = "i386" ]; then
exe="linux-i386"
fi
fi

if [ "${exe}" == "" ]; then
if [ "$(which go)" = "" ]; then
echo "go must be installed to use this gh extension on this platform"
exit 1
fi

exe="cmd.out"

cd "${extensionPath}" > /dev/null
go build -o "${exe}"
cd - > /dev/null
else
if [[ ! -x "${extensionPath}/bin/${exe}" ]]; then
mkdir -p bin
rm -f "${extensionPath}/bin/*"
gh release -R"${repo}" download -p "${exe}" --dir="${extensionPath}/bin"
chmod +x "${extensionPath}/bin/${exe}"
fi
fi

exec "${extensionPath}/bin/${exe}" "$@"
21 changes: 21 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e

# TODO ARM support. figure out mapping to uname -m output.

tag="${1}"

if [ "${tag}" == "" ]; then
echo "tag argument required"
exit 1
fi

rm -rf dist
GOOS=darwin GOARCH=amd64 go build -o "dist/darwin-x86_64"
GOOS=darwin GOARCH=arm64 go build -o "dist/darwin-arm64"
GOOS=linux GOARCH=386 go build -o "dist/linux-i386"
GOOS=linux GOARCH=amd64 go build -o "dist/linux-x86_64"
GOOS=windows GOARCH=386 go build -o "dist/windows-i386"
GOOS=windows GOARCH=amd64 go build -o "dist/windows-x86_64"

gh release create $tag ./dist/* --title="${tag}" --notes "${tag}"

0 comments on commit ae6d757

Please sign in to comment.