-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
147 additions
and
0 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,63 @@ | ||
name: Publish Binaries | ||
|
||
on: | ||
push: | ||
# tags: | ||
# - "v*.*.*" | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
os: [linux, macos, windows] | ||
arch: [amd64, arm64] | ||
|
||
steps: | ||
- name: git checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@main | ||
|
||
- name: Magic cache | ||
uses: DeterminateSystems/magic-nix-cache-action@main | ||
|
||
- name: Build Kardinal CLI images | ||
id: build-cli | ||
shell: bash | ||
run: | | ||
path=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths) | ||
echo "path=$path" >> $GITHUB_OUTPUT | ||
- name: Access it | ||
run: | | ||
echo "the secret number is ${{ steps.build-cli.outputs.path }}" | ||
- name: Upload release assets | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ${{ steps.build-cli.outputs.path }}/bin/${{ matrix.os }}_${{ matrix.arch }}/kardinal.cli | ||
asset_name: kardinal-${{ matrix.os }}-${{ matrix.arch }} | ||
asset_content_type: application/octet-stream | ||
|
||
create-release: | ||
needs: build-and-publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false |
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
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,59 @@ | ||
#!/bin/bash | ||
|
||
REPO="owner/repo" # Replace with the actual repository, e.g., "cli/cli" | ||
BINARY_NAME="binary_name" # Replace with the actual binary name, e.g., "gh" | ||
|
||
OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||
ARCH=$(uname -m) | ||
|
||
if [[ "$ARCH" == "x86_64" ]]; then | ||
ARCH="amd64" | ||
elif [[ "$ARCH" == "arm64" ]]; then | ||
ARCH="arm64" | ||
elif [[ "$ARCH" == "aarch64" ]]; then | ||
ARCH="arm64" | ||
elif [[ "$ARCH" == "i386" ]]; then | ||
ARCH="386" | ||
fi | ||
|
||
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') | ||
|
||
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_RELEASE/${BINARY_NAME}-${OS}-${ARCH}.tar.gz" | ||
curl -L $DOWNLOAD_URL -o /tmp/${BINARY_NAME}.tar.gz | ||
|
||
tar -xzf /tmp/${BINARY_NAME}.tar.gz -C /tmp | ||
sudo mv /tmp/$BINARY_NAME /usr/local/bin/$BINARY_NAME | ||
|
||
rm /tmp/${BINARY_NAME}.tar.gz | ||
|
||
if [ -f /usr/local/bin/$BINARY_NAME ]; then | ||
if [ -d /usr/share/bash-completion/completions ]; then | ||
sudo curl -L "https://raw.githubusercontent.com/$REPO/$LATEST_RELEASE/completions/$BINARY_NAME.bash" -o /usr/share/bash-completion/completions/$BINARY_NAME | ||
source /usr/share/bash-completion/completions/$BINARY_NAME | ||
fi | ||
|
||
if [ -d ~/.zsh/completions ]; then | ||
sudo curl -L "https://raw.githubusercontent.com/$REPO/$LATEST_RELEASE/completions/_$BINARY_NAME" -o ~/.zsh/completions/_$BINARY_NAME | ||
fpath=(~/.zsh/completions $fpath) | ||
autoload -Uz compinit && compinit | ||
elif [ -d /usr/local/share/zsh/site-functions ]; then | ||
sudo curl -L "https://raw.githubusercontent.com/$REPO/$LATEST_RELEASE/completions/_$BINARY_NAME" -o /usr/local/share/zsh/site-functions/_$BINARY_NAME | ||
fi | ||
|
||
if [ -d ~/.config/fish/completions ]; then | ||
sudo curl -L "https://raw.githubusercontent.com/$REPO/$LATEST_RELEASE/completions/$BINARY_NAME.fish" -o ~/.config/fish/completions/$BINARY_NAME.fish | ||
elif [ -d /usr/share/fish/vendor_completions.d ]; then | ||
sudo curl -L "https://raw.githubusercontent.com/$REPO/$LATEST_RELEASE/completions/$BINARY_NAME.fish" -o /usr/share/fish/vendor_completions.d/$BINARY_NAME.fish | ||
fi | ||
fi | ||
|
||
echo "$BINARY_NAME has been installed successfully!" | ||
|
||
if ! command -v $BINARY_NAME &>/dev/null; then | ||
echo "export PATH=\$PATH:/usr/local/bin" >>~/.bashrc | ||
source ~/.bashrc | ||
echo "export PATH=\$PATH:/usr/local/bin" >>~/.zshrc | ||
source ~/.zshrc | ||
echo "set -gx PATH \$PATH /usr/local/bin" >>~/.config/fish/config.fish | ||
source ~/.config/fish/config.fish | ||
fi |