# deployer
Deployer is a relatively simple, yet powerful localhost CI/CD instrument.

## Features
1. Local and remote pipeline execution.
2. Two pipeline drivers: standard (Deployer) and pure shell.
3. **Auto-generate** Docker/Podman and Ansible configs and run pipelines inside images or at remote hosts.
4. Export pipelines to shell scripts, **GitHub Actions** & **GitLab CI** configurations, and **systemd** services.
5. Resolve variables for actions with `.env`-files, any shell command or even **HashiCorp Vault KV2 storage**.
6. Move build & run caches away of your project's directory. Only artifacts and `.depl/config.yaml` file.
7. Watch and rebuild your project automatically via `depl watch`.
8. Use internal versioned content storage and autopatching system on pipeline runs.
## Usability features
1. YAML configuration format, but you may use only your terminal with Deployer's TUI.
2. Global localhost action and pipeline registries.
3. Built-in documentation via `depl docs`.
4. Automatic checks of actions requirements before pipeline execution.
5. Automatic artifacts delivery to `./artifacts` folder.
6. Wide selection of settings and launch options.
## Migration guide
If you encounter problems after updating Deployer, especially after moving from `1.x` to `2.x`, please read [Migration Guide](MIGRATIONS.md).
## Documentation
For Deployer config specification, proceed to [DOCS.md](./DOCS.md) or run `depl docs`.
This repository also have content examples, see [README.md](./content-examples/README.md).
## Build
Well, the building process is very easy. You need to install Rust first:
```bash
After installation, execute this:
```bash
cargo install depl
```
That's it! Now you have `/home/username/.cargo/bin/depl` binary. Modify the `PATH` variable, if you need to.
## Usage
Let's assume that you need to make a pipeline to build and compress your Rust project.
First of all, let's create a simple action.
```bash
depl new action
```
For example, let's name it `UPX Compress`. The short name will be `upx`, the version - `0.1.0`.
The full YAML is:
```yaml
info: upx@0.1.0
requirements:
- type: exists_any
paths:
- /bin/upx
- /usr/bin/upx
- ~/.local/bin/upx
action:
type: staged
stage: build
cmd: upx %af%
placeholders:
- "%af%"
```
If you're not familiar with UPX, consider visiting it's [home page](https://upx.github.io/).
So, let's create a pipeline that will build the binary from the Rust code with preinstalled `cargo-release@0.1.0` action and then compress this binary with `upx@0.1.0`.
```bash
depl new pipeline
```
The full YAML is:
```yaml
title: pack
info: pack@0.1.0
default: true
artifacts:
- from: target/release/my-app
to: my-app
actions:
- title: Build my app in release mode
used: cargo-release@0.1.0
- title: Compress my app
used: upx@0.1.0
```
Note that you can change the inner content of actions inside pipelines, and also can change the inner content of pipelines and their actions if these pipelines assigned to your project. The changes will not affect actions and pipelines from Deployer's Registries.
You can view your actions and pipelines and get it in YAML by simple commands:
```bash
depl ls actions
depl ls pipelines
depl cat action upx@0.1.0
depl cat pipeline pack@0.1.0
```
And, of course, load actions and pipelines from YAML files by:
```bash
depl new action -f {your-action.yaml}
```
The next step is to init the project.
```bash
cd my-rust-project
depl init
depl edit .
```
You should add some actions and specify project variables that you'll use. For our example, add simple variable with `target/release/my-app` value. Also add `cargo-release@0.1.0` and `upx@0.1.0` actions from actions Registry. And not forget to add `Cargo.lock` file and `target` folder to cache files to prevent syncing project folder cache with run folder cache (without specifying this; see `depl run --help` for more).
After all you will get this `.depl/config.yaml`:
```yaml
project_name: my-app
version: 8
ignore_files:
- .git
cache_files:
- Cargo.lock
- target
variables:
my-var:
value:
type: plain
value: target/release/my-app
actions:
- info: cargo-release@0.1.0
tags:
- rust
- cargo
requirements:
- type: exists_any
paths:
- /bin/cargo
- ~/.cargo/bin/cargo
action:
type: staged
stage: build
cmd: cargo build --release
- info: upx@0.1.0
requirements:
- type: exists_any
paths:
- /bin/upx
- /usr/bin/upx
- ~/.local/bin/upx
action:
type: staged
stage: build
cmd: upx %af%
placeholders:
- "%af%"
pipelines:
- title: pack
desc: Got from `pack`.
info: pack@0.1.0
default: true
artifacts:
- from: target/release/my-app
to: my-app
actions:
- title: Build my app in release mode
used: cargo-release@0.1.0
- title: Compress my app
used: upx@0.1.0
with:
"%af%": my-var
```
Having only `.depl/config.yaml` inside your project's root, you can completely share your build/deploy configurations.
At the end, let's build the project!
```bash
depl run
# see the run options: you can share cache files and folders by symlinking or copying
depl run --help
depl run -fc
# or explicitly specify the project pipeline's short name - `build-and-compress`
depl run pack
# create pipeline with `Observe` action and start development server with auto-rebuild
depl watch build-and-deploy-devel
```
For other options, check:
```bash
depl run -h
```