Skip to content

Commit

Permalink
Adiciona lançamento automático do crate (#34)
Browse files Browse the repository at this point in the history
* starts deployment workflow

* fixes imports

* adds metadata

* updates Cargo.toml

* adds deployment workflow
  • Loading branch information
brenomfviana authored Dec 14, 2023
1 parent 872c417 commit 5e46841
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: deploy

on:
release:
types: [created]

env:
CARGO_TERM_COLOR: always

jobs:
runs-on: ubuntu-latest
steps:
- name: Faz checkout no Pull Request
uses: actions/checkout@v3

- name: Instala o Nix
run: |
BASE_URL='https://raw.githubusercontent.com/ES-Nix/get-nix/' \
&& SHA256=87fa0f1dbfdd28a1f99b39d5bd4dcc39de97bc64 \
&& NIX_RELEASE_VERSION='2.10.2' \
&& curl -fsSL "${BASE_URL}""$SHA256"/get-nix.sh | sh -s -- ${NIX_RELEASE_VERSION} \
&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh \
&& . ~/."$(basename $SHELL)"rc \
&& export TMPDIR=/tmp \
&& nix flake --version \
&& nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \
&& curl -fsSL https://raw.githubusercontent.com/ES-Nix/get-nix/"$SHA256"/install_direnv_and_nix_direnv.sh | sh \
&& . ~/."$(basename $SHELL)"rc \
&& direnv --version
echo "$HOME"/.nix-profile/bin >> $GITHUB_PATH
- name: Build
run: nix develop .# --command sh -c 'cd brado && cargo build --release --verbose'

- name: Deploy
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: nix develop .# --command sh -c 'cd brado && cargo login --registry $CARGO_REGISTRY_TOKEN && cargo publish'
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
run: nix develop .# --command sh -c 'cd brado && cargo build --verbose'

- name: Run tests
run: nix develop .# --command sh -c 'cd brado && cargo test --verbose'
run: nix develop .# --command sh -c 'cd brado && cargo test --verbose'

clippy:
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions brado/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
name = "brado"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
license = "MIT"
readme = "../README.md"
description = "brado is a brazilian docs validator"
homepage = "https://github.com/brenomfviana/brado"
documentation = "https://docs.rs/brado"
repository = "https://github.com/brenomfviana/brado"
keywords = ["brazilian", "docs", "validator"]
authors = ["Breno Viana", "Pedro Regis"]

[dependencies]
1 change: 0 additions & 1 deletion brado/src/docs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ pub mod cnpj;
pub mod common;
pub mod cpf;
pub mod doc;
pub use doc::Document;
13 changes: 12 additions & 1 deletion brado/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
//! # brado documentation
//!
//! brado is a brazilian docs validator.
//!
//! ## Example
//! ```
//! use brado;
//! use brado::Document;
//! let cpf_doc: Document = Document::new("639.292.470-11");
//! brado::cpf::validate(&cpf_doc, true, false);
//! ```
mod docs;
pub use crate::docs::cnpj;
pub use crate::docs::cpf;
pub use crate::docs::Document;
pub use crate::docs::doc::Document;

0 comments on commit 5e46841

Please sign in to comment.