Skip to content
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

feat: deploy command #295

Merged
merged 59 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4d7f371
feat: draft implementation for deploy command
aorumbayev Jun 28, 2023
49edba2
chore: addressing PR comments
aorumbayev Jun 29, 2023
e676eab
chore: updating lockfile
aorumbayev Jun 29, 2023
73e3104
docs: refreshing docs
aorumbayev Jun 29, 2023
4ff512e
refactor: further refining code; more tests; documentation
aorumbayev Jun 30, 2023
1261de0
feat: adding ability for bootstrap to work with any .env*.template files
aorumbayev Jun 30, 2023
c9c7af7
chore: typo fix
aorumbayev Jun 30, 2023
6c915d9
chore: fixing typo
aorumbayev Jun 30, 2023
40f5920
chore: lock file maintenance; bumping ruff
aorumbayev Jun 30, 2023
8ad8e5b
chore: fixing unit tests
aorumbayev Jun 30, 2023
c6a5774
chore: fixing windows support
aorumbayev Jun 30, 2023
753ed1f
chore: windows support
aorumbayev Jun 30, 2023
05bd99f
chore: addressing pr comments
aorumbayev Jul 3, 2023
41ff675
chore: addressing pr comments
aorumbayev Jul 3, 2023
17ba836
docs: refining docs
aorumbayev Jul 3, 2023
ce1616f
chore: fixing unit tests on ubuntu
aorumbayev Jul 3, 2023
1b821bf
chore: windows tweaks for path
aorumbayev Jul 3, 2023
668c4f0
refactor: tiny tweak in log message
aorumbayev Jul 3, 2023
5e2d12f
**STASH**
achidlow Jul 4, 2023
7fe605c
**STASH**
achidlow Jul 4, 2023
3edf14b
**STASH**
achidlow Jul 4, 2023
d836237
refactor: addressing final pr comments from Adam
aorumbayev Jul 4, 2023
b30ca2a
Merge remote-tracking branch 'origin/main' into deploy-command
aorumbayev Jul 4, 2023
fb387f8
docs: tweaking docs
aorumbayev Jul 4, 2023
79ddc88
wip
achidlow Jul 6, 2023
ee76828
wip
achidlow Jul 6, 2023
aa75962
wip
achidlow Jul 6, 2023
e40a030
wip
achidlow Jul 6, 2023
d726806
wip
achidlow Jul 6, 2023
c525d0b
wip
achidlow Jul 6, 2023
dfbce1c
wip
achidlow Jul 6, 2023
d1ce514
wip
achidlow Jul 7, 2023
10de20f
wip
achidlow Jul 7, 2023
85bc0b9
wip
achidlow Jul 7, 2023
4fb44d1
wip
achidlow Jul 7, 2023
77fa424
wip
achidlow Jul 10, 2023
bec9a02
wip
achidlow Jul 10, 2023
09cd7e6
wip
achidlow Jul 10, 2023
bfc5d3a
chore: addressing pr comments
aorumbayev Jul 10, 2023
a12b9db
chore: updating docs
aorumbayev Jul 10, 2023
cff8b03
chore: testing ci
aorumbayev Jul 10, 2023
88aa525
chore: fixing ci
aorumbayev Jul 10, 2023
ef82008
chore: addressing pr comments removing case insensitivity
aorumbayev Jul 11, 2023
0262fd3
get tests working locally
achidlow Jul 11, 2023
0f35a0d
make called args for proc_mock into single type
achidlow Jul 11, 2023
12fba64
deploy testing WIP
achidlow Jul 11, 2023
bf06ed9
refactor: refining deploy tests
aorumbayev Jul 11, 2023
5c97c50
chore: fixing ci env var override
aorumbayev Jul 11, 2023
7a593cf
refactor: shlex disabling posix on windows
aorumbayev Jul 11, 2023
e269562
fix: do not split command when parsing on windows
daniel-makerx Jul 12, 2023
30304c3
test: fix python path on windows in tests
daniel-makerx Jul 12, 2023
75cc1a9
test: remove unnecessary replacements
daniel-makerx Jul 12, 2023
505ecf4
test: add additional test for list style command in config
daniel-makerx Jul 12, 2023
9d21ba0
fix: return to use shlex posix flag
daniel-makerx Jul 12, 2023
ce159b4
fix: try mslex to split on windows
daniel-makerx Jul 12, 2023
8d8f6f3
test: use a command that is compatible on windows
daniel-makerx Jul 12, 2023
8641e8b
test: remove unused approvals
daniel-makerx Jul 12, 2023
6f703de
docs: refining documentation
aorumbayev Jul 12, 2023
d40700f
Update docs/features/deploy.md
aorumbayev Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 62 additions & 11 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,51 @@
- [Options](#options-1)
- [--force](#--force)
- [all](#all)
- [Options](#options-2)
- [--interactive, --non-interactive, --ci](#--interactive---non-interactive---ci)
- [env](#env)
- [Options](#options-3)
- [--interactive, --non-interactive, --ci](#--interactive---non-interactive---ci-1)
- [npm](#npm)
- [poetry](#poetry)
- [completions](#completions)
- [install](#install)
- [Options](#options-2)
- [Options](#options-4)
- [--shell ](#--shell-)
- [uninstall](#uninstall)
- [Options](#options-3)
- [Options](#options-5)
- [--shell ](#--shell--1)
- [config](#config)
- [version-prompt](#version-prompt)
- [Arguments](#arguments)
- [ENABLE](#enable)
- [deploy](#deploy)
- [Options](#options-6)
- [-C, --command ](#-c---command-)
- [--interactive, --non-interactive, --ci](#--interactive---non-interactive---ci-2)
- [-P, --path ](#-p---path-)
- [Arguments](#arguments-1)
- [ENVIRONMENT_NAME](#environment_name)
- [doctor](#doctor)
- [Options](#options-4)
- [Options](#options-7)
- [-c, --copy-to-clipboard](#-c---copy-to-clipboard)
- [explore](#explore)
- [Arguments](#arguments-1)
- [Arguments](#arguments-2)
- [NETWORK](#network)
- [generate](#generate)
- [client](#client)
- [Options](#options-5)
- [Options](#options-8)
- [-o, --output ](#-o---output-)
- [-l, --language ](#-l---language-)
- [Arguments](#arguments-2)
- [Arguments](#arguments-3)
- [APP_SPEC_PATH_OR_DIR](#app_spec_path_or_dir)
- [goal](#goal)
- [Options](#options-6)
- [Options](#options-9)
- [--console](#--console)
- [Arguments](#arguments-3)
- [Arguments](#arguments-4)
- [GOAL_ARGS](#goal_args)
- [init](#init)
- [Options](#options-7)
- [Options](#options-10)
- [-n, --name ](#-n---name-)
- [-t, --template ](#-t---template-)
- [--template-url ](#--template-url-)
Expand All @@ -59,11 +70,11 @@
- [console](#console)
- [explore](#explore-1)
- [logs](#logs)
- [Options](#options-8)
- [Options](#options-11)
- [--follow, -f](#--follow--f)
- [--tail ](#--tail-)
- [reset](#reset)
- [Options](#options-9)
- [Options](#options-12)
- [--update, --no-update](#--update---no-update)
- [start](#start)
- [status](#status)
Expand Down Expand Up @@ -120,6 +131,12 @@ Runs all bootstrap sub-commands in the current directory and immediate sub direc
algokit bootstrap all [OPTIONS]
```

### Options


### --interactive, --non-interactive, --ci
Enable/disable interactive prompts. If the CI environment variable is set, defaults to non-interactive

### env

Copies .env.template file to .env in the current working directory and prompts for any unspecified values.
Expand All @@ -128,6 +145,12 @@ Copies .env.template file to .env in the current working directory and prompts f
algokit bootstrap env [OPTIONS]
```

### Options


### --interactive, --non-interactive, --ci
Enable/disable interactive prompts. If the CI environment variable is set, defaults to non-interactive

### npm

Runs npm install in the current working directory to install Node.js dependencies.
Expand Down Expand Up @@ -221,6 +244,34 @@ algokit config version-prompt [OPTIONS] [[enable|disable]]
### ENABLE
Optional argument

## deploy

Deploy smart contracts from AlgoKit compliant repository.

```shell
algokit deploy [OPTIONS] [ENVIRONMENT_NAME]
```

### Options


### -C, --command <command>
Custom deploy command. If not provided, will load the deploy command from .algokit.toml file.


### --interactive, --non-interactive, --ci
Enable/disable interactive prompts. If the CI environment variable is set, defaults to non-interactive


### -P, --path <path>
Specify the project directory. If not provided, current working directory will be used.

### Arguments


### ENVIRONMENT_NAME
Optional argument

## doctor

Diagnose potential environment issues that may affect AlgoKit
Expand Down
127 changes: 127 additions & 0 deletions docs/features/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# AlgoKit Deploy Feature Documentation

Deploy your smart contracts effortlessly to various networks with the AlgoKit Deploy feature. This feature is essential for automation in CI/CD pipelines and for seamless deployment to various Algorand network environments.

## Usage

```sh
$ algokit deploy [OPTIONS] [ENVIRONMENT_NAME]
```

This command deploys smart contracts from an AlgoKit compliant repository to the specified network.

### Options

- `--command, -C TEXT`: Specifies a custom deploy command. If this option is not provided, the deploy command will be loaded from the `.algokit.toml` file.
- `--interactive / --non-interactive, --ci`: Enables or disables the interactive prompt for mnemonics. When the CI environment variable is set, it defaults to non-interactive.
- `--path, -P DIRECTORY`: Specifies the project directory. If not provided, the current working directory will be used.
- `-h, --help`: Show this message and exit.

## Environment files

AlgoKit `deploy` employs both a general and network-specific environment file strategy. This allows you to set environment variables that are applicable across all networks and others that are specific to a given network.

The general environment file (`.env`) should be placed at the root of your project. This file will be used to load environment variables that are common across deployments to all networks.

For each network you're deploying to, you can optionally have a corresponding `.env.[network_name]` file. This file should contain environment variables specific to that network. Network-specific environment variables take precedence over general environment variables.

The directory layout would look like this:

```md
.
├── ... (your project files and directories)
├── .algokit.toml # Configuration file for AlgoKit
├── .env # (OPTIONAL) General environment variables common across all deployments
└── .env.[{mainnet|testnet|localnet|betanet|custom}] # (OPTIONAL) Environment variables specific to deployments to a network
```

> ⚠️ Please note that creating `.env` and `.env.[network_name]` files is only necessary if you're deploying to a custom network or if you want to override the default network configurations provided by AlgoKit. AlgoKit comes with predefined configurations for popular networks like `TestNet`, `MainNet`, `BetaNet`, or AlgoKit's `LocalNet`.

The logic for loading environment variables is as follows:

- If a `.env` file exists, the environment variables contained in it are loaded first.
- If a `.env.[network_name]` file exists, the environment variables in it are loaded, overriding any previously loaded values from the `.env` file for the same variables.

## AlgoKit Configuration File

AlgoKit uses a configuration file called `.algokit.toml` in the root of your project. The configuration file can be created using the `algokit init` command. This file will define the deployment commands for the various network environments that you want to target.

Here's an example of what the `.algokit.toml` file might look like. When deploying it will prompt for the `DEPLOYER_MNEMONIC` secret unless it is already defined as an environment variable or is deploying to localnet.

```toml
[algokit]
min_version = "v{lastest_version}"

[deploy]
command = "poetry run python -m smart_contracts deploy"
environment_secrets = [
"DEPLOYER_MNEMONIC",
]

[deploy.localnet]
environment_secrets = []
```

The `command` key under each `[deploy.{network_name}]` section should contain a string that represents the deployment command for that particular network. If a `command` key is not provided in a network-specific section, the command from the general `[deploy]` section will be used.

The `environment_secrets` key should contain a list of names of environment variables that should be treated as secrets. This can be defined in the general `[deploy]` section, as well as in the network-specific sections. The environment-specific secrets will be added to the general secrets during deployment.

The `[algokit]` section with the `min_version` key allows you to specify the minimum version of AlgoKit that the project requires.

This way, you can define common deployment logic and environment secrets in the `[deploy]` section, and provide overrides or additions for specific environments in the `[deploy.{environment_name}]` sections.

## Deploying to a Specific Network

The command requires a `ENVIRONMENT` argument, which specifies the network environment to which the smart contracts will be deployed. Please note, the `environment` argument is case-sensitive.

Example:

```sh
$ algokit deploy testnet
```

This command deploys the smart contracts to the testnet.

## Custom Project Directory

By default, the deploy command looks for the `.algokit.toml` file in the current working directory. You can specify a custom project directory using the `--project-dir` option.

Example:

```sh
$ algokit deploy testnet --project-dir="path/to/project"
```

## Custom Deploy Command

You can provide a custom deploy command using the `--custom-deploy-command` option. If this option is not provided, the deploy command will be loaded from the `.algokit.toml` file.

Example:

```sh
$ algokit deploy testnet --custom-deploy-command="your-custom-command"
```

## CI Mode

By using the `--ci` or `--non-interactive` flag, you can skip the interactive prompt for mnemonics.

This is useful in CI/CD environments where user interaction is not possible. When using this flag, you need to make sure that the mnemonics are set as environment variables.

Example:

```sh
$ algokit deploy testnet --ci
```

## Example of a Full Deployment

```sh
$ algokit deploy testnet --custom-deploy-command="your-custom-command"
```

This example shows how to deploy smart contracts to the testnet using a custom deploy command. This also assumes that .algokit.toml file is present in the current working directory, and .env.testnet file is present in the current working directory and contains the required environment variables for deploying to TestNet environment.

## Further Reading

For in-depth details, visit the [deploy](../cli/index.md#deploy) section in the AlgoKit CLI reference documentation.
Loading