Skip to content

Commit

Permalink
Feature/binary name, readme, and versioning updates (#25)
Browse files Browse the repository at this point in the history
* rename binary to astria-cli-go. update readme with instructions for running from gh release

* just linting commands. markdown lint conf

* new action to create release on git tag push. refactor existing release action to pass ldflags

* rename to astria-go

* fix format of ldflag. remove create-release action

* strings

* strings

* strings

* strings

* correct path for var

* use ref name instead of full ref
  • Loading branch information
steezeburger authored Mar 29, 2024
1 parent 4dae514 commit 786e51b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ permissions:
packages: write

jobs:
releases-matrix:
name: Release Go Binary
build-for-release:
name: Build For Release
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -24,5 +24,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
ldflags: >
-X github.com/astria/astria-cli-go/cmd.version=${{ github.ref_name }}
project_path: "./"
binary_name: "astria-cli"
binary_name: "astria-go"
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"MD013": {
"line_length": 80,
"code_block_line_length": 120,
"tables": false
}
}
69 changes: 47 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
# The Astria Development CLI
# The Astria CLI

The `astria-dev` cli is a tool designed to make local rollup development as
simple and dependency free as possible.
The `astria-go` cli is a tool designed to make local rollup development as
simple and dependency free as possible. It provides functionality to easily run
the Astria stack and interact with the Sequencer.

# Locally Build the CLI
## Install and Run CLI from GitHub release

The CLI binaries are available for download from the
[releases page](https://github.com/astriaorg/astria-cli-go/releases). There are
binaries available for macOS and Linux, for both x86_64 and arm64 architectures.

```bash
# download the binary for your platform, e.g. macOS silicon
curl -L https://github.com/astriaorg/astria-cli-go/releases/download/v0.3.0/astria-cli-v0.3.0-darwin-arm64.tar.gz \
--output astria-go.tar.gz
# extract the binary
tar -xzvf astria-go.tar.gz
# run the binary and check version
./astria-go version

# you can move the binary to a location in your PATH if you'd like
mv astria-go /usr/local/bin/
```

## Locally Build and Run the CLI

Dependencies: (only required for development)

- [GO](https://go.dev/doc/install)
- [just](https://github.com/casey/just)

```
```bash
git clone [email protected]:astriaorg/astria-cli-go.git
cd astria-cli-go
just build
just run "dev init"
just run "dev run"
```

This will download, configure, and run the following binaries of these applications:
This will download, configure, and run the following binaries of these
applications:

| App | Version |
| ---------------- | ------- |
Expand All @@ -38,21 +59,23 @@ Astria's apis correctly.

Requires go version 1.20 or newer.

You may also need to update your `gopls` settings in your editor for build tags to allow for
correct parsing of the build tags in the code. This will depend on your IDE, but
for VS Code you can open your settings and add:
You may also need to update your `gopls` settings in your editor for build tags
to allow for correct parsing of the build tags in the code. This will depend on
your IDE, but for VS Code you can open your settings and add:

```
"gopls": {
"buildFlags": ["-tags=darwin arm64 amd64 linux"]
```json
{
"gopls": {
"buildFlags": ["-tags=darwin arm64 amd64 linux"]
}
}
```

The cli is built using [Cobra](https://github.com/spf13/cobra). Once you've
pulled the repo you can install the `cobra-cli` as follows to add new commands
for development:

```
```bash
# install cobra-cli
go install github.com/spf13/cobra-cli@latest
# add new command, e.g. `run`
Expand All @@ -61,12 +84,14 @@ cobra-cli add <new-command>

### Available Commands

| Command | Description |
| --------------- | ----------------------------------------------------------------------------------- |
| `version` | Prints the cli version. |
| `help` | Show help. |
| `dev` | Root command for cli development functionality. |
| `dev init` | Downloads binaries and initializes the local environment. |
| `dev run` | Runs a minimal, local Astria stack. |
| `dev clean` | Deletes the local data for the Astria stack. |
| `dev clean all` | Deletes the local data, downloaded binaries, and config files for the Astria stack. |
| Command | Description |
|----------------------------|-------------------------------------------------------------------------------------|
| `version` | Prints the cli version. |
| `help` | Show help. |
| `dev` | Root command for cli development functionality. |
| `dev init` | Downloads binaries and initializes the local environment. |
| `dev run` | Runs a minimal, local Astria stack. |
| `dev clean` | Deletes the local data for the Astria stack. |
| `dev clean all` | Deletes the local data, downloaded binaries, and config files for the Astria stack. |
| `sequencer create-account` | Generate an account for the Sequencer. |
| `sequencer get-balance` | Get the balance of an account on the Sequencer. |
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "astria-cli",
Use: "astria-go",
Short: "A CLI to run Astria, interact with the Sequencer, deploy rollups, and more.",
}

Expand Down
9 changes: 6 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import (
"github.com/spf13/cobra"
)

var version = "v0.2.0"
// version is set at build time via ldflags in the build-for-release workflow
var version string

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version.",
Long: `Print the version of the CLI tool.`,
Short: "Print the version of the CLI.",
Run: func(cmd *cobra.Command, args []string) {
printVersion()
},
}

func printVersion() {
if version == "" {
version = "development"
}
fmt.Println(version)
}

Expand Down
24 changes: 22 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# list all available commands
default:
@just --list
@just --list

# build the binary for the cli
build:
go build -o bin/astria-cli
go build -o bin/astria-go

# test go code
test:
Expand All @@ -16,6 +16,26 @@ alias t := test
fmt:
go fmt ./...

default_lang := 'all'

# Can lint 'go', 'md', or 'all'. Defaults to all.
lint lang=default_lang:
@just _lint-{{lang}}

alias l := lint

@_lint-all:
@just _lint-go
@just _lint-md

[no-exit-message]
_lint-go:
golangci-lint run

[no-exit-message]
_lint-md:
markdownlint-cli2 "**/*.md" "#bin" "#.github"

defaultargs := ''
# run the cli. takes quoted cli command to run, e.g. `just run "dev init"`. logs cli output to tview_log.txt
run args=defaultargs:
Expand Down

0 comments on commit 786e51b

Please sign in to comment.