-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Build binaries for all architectures
- Loading branch information
Showing
3 changed files
with
116 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
release: | ||
name: Publish Go Binaries | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64 | ||
goos: [linux, windows, darwin] | ||
goarch: ["386", amd64] | ||
exclude: | ||
- goarch: "386" | ||
goos: darwin | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: wangyoucao577/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
goversion: "https://dl.google.com/go/go1.16.6.linux-amd64.tar.gz" | ||
extra_files: LICENSE README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
name: Build and test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
|
@@ -15,25 +15,20 @@ jobs: | |
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
- name: Build | ||
run: make build | ||
- name: Commit and tag | ||
uses: EndBug/add-and-commit@v7 # You can change this to use a specific version. | ||
run: | | ||
make build | ||
- name: "Build Changelog" | ||
id: build_changelog | ||
uses: mikepenz/release-changelog-builder-action@v2 | ||
with: | ||
add: "bin/cli" | ||
author_name: Commit Bot | ||
author_email: [email protected] | ||
message: "Release v${{ github.run_number }}" | ||
push: true | ||
tag: "v${{ github.run_number }}" | ||
- name: Publish Release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
commitMode: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
automatic_release_tag: "v${{ github.run_number }}" | ||
files: | | ||
bin/cli | ||
- name: Publish to homebrew tap | ||
uses: izumin5210/action-homebrew-tap@latest | ||
with: | ||
tap: usecloudstate/homebrew-cli | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag_name: v${{ github.run_number }} | ||
release_name: v${{ github.run_number }} | ||
body: ${{steps.github_release.outputs.changelog}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/bin/bash | ||
{ | ||
set -e | ||
SUDO='' | ||
if [ "$(id -u)" != "0" ]; then | ||
SUDO='sudo' | ||
echo "This script requires superuser access." | ||
echo "You will be prompted for your password by sudo." | ||
# clear any previous sudo permission | ||
sudo -k | ||
fi | ||
|
||
|
||
# run inside sudo | ||
$SUDO bash <<SCRIPT | ||
set -e | ||
echoerr() { echo "\$@" 1>&2; } | ||
if [[ ! ":\$PATH:" == *":/usr/local/bin:"* ]]; then | ||
echoerr "Your path is missing /usr/local/bin, you need to add this to use this installer." | ||
exit 1 | ||
fi | ||
if [ "\$(uname)" == "Darwin" ]; then | ||
OS=darwin | ||
elif [ "\$(expr substr \$(uname -s) 1 5)" == "Linux" ]; then | ||
OS=linux | ||
else | ||
echoerr "This installer is only supported on Linux and MacOS" | ||
exit 1 | ||
fi | ||
ARCH="\$(uname -m)" | ||
if [ "\$ARCH" == "x86_64" ]; then | ||
ARCH=x64 | ||
elif [[ "\$ARCH" == aarch* ]]; then | ||
ARCH=arm | ||
else | ||
echoerr "unsupported arch: \$ARCH" | ||
exit 1 | ||
fi | ||
mkdir -p /usr/local/lib | ||
cd /usr/local/lib | ||
rm -rf cloudstate | ||
rm -rf ~/.local/share/cloudstate/client | ||
if [ \$(command -v xz) ]; then | ||
URL=https://cli-assets.cloudstate.com/cloudstate-\$OS-\$ARCH.tar.xz | ||
TAR_ARGS="xJ" | ||
else | ||
URL=https://cli-assets.cloudstate.com/cloudstate-\$OS-\$ARCH.tar.gz | ||
TAR_ARGS="xz" | ||
fi | ||
echo "Installing CLI from \$URL" | ||
if [ \$(command -v curl) ]; then | ||
curl "\$URL" | tar "\$TAR_ARGS" | ||
else | ||
wget -O- "\$URL" | tar "\$TAR_ARGS" | ||
fi | ||
# delete old cloudstate bin if exists | ||
rm -f \$(command -v cloudstate) || true | ||
rm -f /usr/local/bin/cloudstate | ||
ln -s /usr/local/lib/cloudstate/bin/cloudstate /usr/local/bin/cloudstate | ||
# on alpine (and maybe others) the basic node binary does not work | ||
# remove our node binary and fall back to whatever node is on the PATH | ||
/usr/local/lib/cloudstate/bin/node -v || rm /usr/local/lib/cloudstate/bin/node | ||
SCRIPT | ||
# test the CLI | ||
LOCATION=$(command -v cloudstate) | ||
echo "cloudstate installed to $LOCATION" | ||
} |