-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script #1
Open
DelevoXDG
wants to merge
31
commits into
main
Choose a base branch
from
zdobnikau/add-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add script #1
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
4480dca
wip
DelevoXDG 5b513bc
Include uninstall docs for 'scarb' and 'starknet-foundry'
DelevoXDG ba89422
Improve plugin installation; Misc
DelevoXDG e4771ed
Add bold info messages on supported platforms
DelevoXDG abb7286
Replace bulk installation with individual version installation
DelevoXDG bd3bedd
Refactor global version setting
DelevoXDG eb3222a
Reinstall foundry to ensure latest version of USC is installed
DelevoXDG e2acb49
refactor
DelevoXDG 8492df3
refactor
DelevoXDG 7b97b9a
wip
DelevoXDG b8e5bbe
wip
DelevoXDG b97cd29
Add version and help args
DelevoXDG a095e67
wip
DelevoXDG 92ce4a1
wip
DelevoXDG 5c0d947
Fix `uninstall_latest_version`
DelevoXDG 4cd9a6b
Add interactive installation for asdf-vm
DelevoXDG 6434249
update description
DelevoXDG 7932825
update shell-based installation instructions
DelevoXDG 503ee7e
Drop support for all shels except bash, zshrc, ash
DelevoXDG 12b03c5
Update asdf-vm installation instructions to use new documentation link
DelevoXDG bedaacf
wip
DelevoXDG 6d12210
misc
DelevoXDG 940a5cb
Add basic CI
DelevoXDG 9230a1f
Update CI
DelevoXDG d35a563
Fix format checks
DelevoXDG 491aded
improve ci
DelevoXDG 426cf35
fix prints
DelevoXDG 7e25f6b
misc
DelevoXDG 1ed9000
misc
DelevoXDG 4fb7c8c
Fetch and install latest version of asdf
DelevoXDG e395d8b
fix
DelevoXDG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,76 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: test ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup asdf | ||
uses: asdf-vm/actions/setup@v3 | ||
|
||
- name: Fetch latest Scarb version from GitHub releases | ||
id: scarb_version | ||
shell: pwsh | ||
run: | | ||
$location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/scarb/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location | ||
$latest_version = ($location -replace '^.*/v','') | ||
echo "Latest Scarb version found is $latest_version" | ||
echo "LATEST=$latest_version" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Fetch latest Starknet Foundry version from GitHub releases | ||
id: snfoundry_version | ||
shell: pwsh | ||
run: | | ||
$location = (Invoke-WebRequest -Uri "https://github.com/foundry-rs/starknet-foundry/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location | ||
$latest_version = ($location -replace '^.*/v','') | ||
echo "Latest Starknet Foundry version found is $latest_version" | ||
echo "LATEST=$latest_version" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Fetch latest Universal Sierra Compiler version from GitHub releases | ||
id: usc_version | ||
shell: pwsh | ||
run: | | ||
$location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/universal-sierra-compiler/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location | ||
$latest_version = ($location -replace '^.*/v','') | ||
echo "Latest Universal Sierra Compiler version found is $latest_version" | ||
echo "LATEST=$latest_version" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Run starknetup | ||
run: ./starknetup.sh | ||
|
||
- name: Check Scarb latest | ||
run: scarb --version | grep "scarb ${{ steps.scarb_version.outputs.LATEST }}" | ||
|
||
- name: Check Starknet Foundry latest | ||
run: | | ||
snforge --version | grep "snforge ${{ steps.snfoundry_version.outputs.LATEST }}" | ||
sncast --version | grep "sncast ${{ steps.snfoundry_version.outputs.LATEST }}" | ||
|
||
- name: Check Universal Sierra Compiler latest | ||
run: universal-sierra-compiler --version | grep "universal-sierra-compiler ${LATEST}" | ||
|
||
shellcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: shellcheck starknetup.sh | ||
|
||
shfmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: mfinelli/setup-shfmt@v3 | ||
- uses: actions/checkout@v4 | ||
- run: shfmt --diff starknetup.sh |
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,186 @@ | ||
#!/bin/sh | ||
# shellcheck shell=dash | ||
|
||
set -eu | ||
|
||
ASDF_INSTALL_DOCS="https://asdf-vm.com/guide/getting-started.html" | ||
SCARB_UNINSTALL_DOCS="https://docs.swmansion.com/scarb/download#uninstall" | ||
STARKNET_FOUNDRY_UNINSTALL_DOCS="PENDING" | ||
SCRIPT_VERSION="0.1.0" | ||
|
||
usage() { | ||
cat <<EOF | ||
The installer for Starknet tools. Installs the latest versions of Scarb, Starknet Foundry and Universal Sierra Compiler using asdf. | ||
|
||
Usage: $0 [OPTIONS] | ||
|
||
Options: | ||
-h, --help Print help | ||
-V, --version Print script version | ||
|
||
EOF | ||
} | ||
|
||
main() { | ||
for arg in "$@"; do | ||
case "$arg" in | ||
-h | --help) | ||
usage | ||
exit 0 | ||
;; | ||
-V | --version) | ||
printf "starknetup %s\n" "$SCRIPT_VERSION" | ||
exit 0 | ||
;; | ||
*) | ||
err "invalid option '$arg'. For more information, try '--help'." | ||
;; | ||
esac | ||
done | ||
|
||
assert_dependencies | ||
assert_not_installed "scarb" $SCARB_UNINSTALL_DOCS | ||
install_latest_asdf_plugin "scarb" | ||
install_latest_version "scarb" | ||
set_global_latest_version "scarb" | ||
|
||
assert_not_installed "starknet-foundry" $STARKNET_FOUNDRY_UNINSTALL_DOCS | ||
install_latest_asdf_plugin "starknet-foundry" | ||
|
||
# Reinstall to ensure the latest version of USC is installed | ||
uninstall_latest_version "starknet-foundry" | ||
install_latest_version "starknet-foundry" | ||
set_global_latest_version "starknet-foundry" | ||
|
||
say "Installation complete" | ||
} | ||
|
||
assert_dependencies() { | ||
need_cmd curl | ||
need_cmd git | ||
if ! check_cmd asdf; then | ||
install_asdf_interactively | ||
fi | ||
} | ||
|
||
assert_not_installed() { | ||
local tool="$1" | ||
local uninstall_docs_url="$2" | ||
|
||
if ! asdf which "$tool" >/dev/null 2>&1; then | ||
if check_cmd "$tool"; then | ||
err "$tool is already installed outside of asdf. Please uninstall it and re-run this script. For uninstallation instructions, refer to $uninstall_docs_url." | ||
fi | ||
fi | ||
} | ||
|
||
install_latest_asdf_plugin() { | ||
local plugin="$1" | ||
if asdf plugin list | grep -q "$plugin"; then | ||
ensure asdf plugin update "$plugin" | ||
else | ||
ensure asdf plugin add "$plugin" | ||
fi | ||
} | ||
|
||
install_latest_version() { | ||
local tool="$1" | ||
ensure asdf install "$tool" latest | ||
} | ||
|
||
uninstall_latest_version() { | ||
local tool="$1" | ||
local latest_version | ||
latest_version=$(asdf latest "$tool") | ||
|
||
if asdf list "$tool" "^${latest_version}$" >/dev/null 2>&1; then | ||
ensure asdf uninstall "$tool" "$latest_version" | ||
fi | ||
} | ||
|
||
set_global_latest_version() { | ||
local tool="$1" | ||
ensure asdf global "$tool" latest | ||
} | ||
|
||
say() { | ||
printf "starknetup: %s\n" "$1" | ||
} | ||
|
||
err() { | ||
say "$1" >&2 | ||
exit 1 | ||
} | ||
|
||
need_cmd() { | ||
if ! check_cmd "$1"; then | ||
err "need '$1' (command not found)" | ||
fi | ||
} | ||
|
||
check_cmd() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
ensure() { | ||
if ! "$@"; then err "command failed: $*"; fi | ||
} | ||
|
||
install_asdf_interactively() { | ||
local _profile | ||
local _pref_shell | ||
local _asdf_path="$HOME/.asdf" | ||
|
||
case ${SHELL:-""} in | ||
*/zsh) | ||
_profile=$HOME/.zshrc | ||
_pref_shell=zsh | ||
;; | ||
*/ash) | ||
_profile=$HOME/.profile | ||
_pref_shell=ash | ||
;; | ||
*/bash) | ||
if [ "$(uname)" = "Darwin" ]; then | ||
_profile=$HOME/.bash_profile | ||
else | ||
_profile=$HOME/.bashrc | ||
fi | ||
_pref_shell=bash | ||
;; | ||
*) | ||
err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." | ||
;; | ||
esac | ||
|
||
if [ -n "$_profile" ]; then | ||
if [ ! -f "$_profile" ]; then | ||
touch "$_profile" | ||
fi | ||
|
||
say "asdf-vm is required. Do you want to install it now? (y/N): " | ||
read -r answer | ||
case $answer in | ||
[Yy]*) | ||
say "Installing asdf-vm...\n" | ||
git clone https://github.com/asdf-vm/asdf.git "$_asdf_path" --branch v0.14.1 | ||
mkaput marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
case $_pref_shell in | ||
zsh | bash | ash) | ||
echo >>"$_profile" && echo ". ${_asdf_path}/asdf.sh" >>"$_profile" | ||
;; | ||
esac | ||
|
||
say "asdf-vm has been installed. Run 'source ${_profile}' or start a new terminal session and re-run this script." | ||
exit 0 | ||
;; | ||
*) | ||
err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." | ||
;; | ||
esac | ||
else | ||
err "asdf-vm is required. Please install it manually and re-run this script. For installation instructions, refer to ${ASDF_INSTALL_DOCS}." | ||
fi | ||
} | ||
|
||
main "$@" || exit 1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocked by foundry-rs/starknet-foundry#2768