Pular para conteúdo

GIT_CREATE_TAG - Criar Tag no Repositório

O que é este Node?

O GIT_CREATE_TAG é o node responsável por criar tags no repositório Git, marcando pontos importantes no histórico como releases e versões.

Por que este Node existe?

Tags são fundamentais para marcar releases e versões estáveis. O GIT_CREATE_TAG existe para:

  1. Versionamento: Marcar releases específicas (v1.0.0, v2.1.3)
  2. Referência: Criar pontos de referência no histórico
  3. Deploy: Identificar versões para deploy
  4. Documentação: Documentar marcos importantes do projeto

Como funciona internamente?

Quando o GIT_CREATE_TAG é executado, o sistema:

  1. Recebe parâmetros: Nome da tag e mensagem opcional
  2. Substitui variáveis: Aplica variáveis do contexto
  3. Determina tipo: Tag anotada (com mensagem) ou lightweight
  4. Executa tag: Roda git tag apropriado
  5. Retorna confirmação: Confirma criação da tag

Código interno (git.executor.ts:158-168):

private async createTag(repoPath: string, tagName: string, tagMessage: string, context: ExecutionContext): Promise<any> {
  const replacedName = this.replaceVariables(tagName, context.variables);
  const replacedMessage = tagMessage ? this.replaceVariables(tagMessage, context.variables) : '';

  const command = tagMessage
    ? `tag -a ${replacedName} -m "${replacedMessage}"`
    : `tag ${replacedName}`;

  const output = await this.execGit(repoPath, command, context);
  return { output, tagCreated: true, tagName: replacedName };
}

Quando você DEVE usar este Node?

Use GIT_CREATE_TAG quando precisar de marcar versões ou releases:

Casos de uso

  1. Release automation: "Criar tag v1.0.0 após deploy bem-sucedido"
  2. Semantic versioning: "Tag automática baseada em tipo de commits"
  3. Milestone marking: "Marcar conclusão de sprint"
  4. Backup points: "Criar tag antes de mudanças maiores"

Quando NÃO usar GIT_CREATE_TAG

  • Tag já existe: Verificar antes para evitar conflito
  • Sem commits: Precisa ter commits para tagear

Parâmetros Detalhados

repositoryPath (string, obrigatório)

O que é: Caminho absoluto para o repositório Git.

Padrão: Nenhum (obrigatório informar)

tagName (string, obrigatório)

O que é: Nome da tag a ser criada. Geralmente segue semantic versioning (v1.0.0).

Padrão: Nenhum (obrigatório informar)

Convenções comuns: - Semantic: v1.2.3, v2.0.0-beta - Date-based: release-2025-10-13 - Custom: deploy-prod-123

Flow completo para testar:

{
  "name": "Teste Git Create Tag - Tag Name",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "input_1",
      "type": "input",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Nome da Tag",
        "parameters": {
          "message": "Digite o nome da tag (ex: v1.0.0):",
          "variable": "tag_name"
        }
      }
    },
    {
      "id": "git_tag_1",
      "type": "git",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Create Tag",
        "operation": "createTag",
        "repositoryPath": "/var/www/app",
        "tagName": "{{tag_name}}",
        "tagMessage": "Release {{tag_name}}",
        "responseVariable": "tag_result"
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Confirmação",
        "parameters": {
          "message": "Tag {{tag_result.tagName}} criada com sucesso!"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "input_1" },
    { "source": "input_1", "target": "git_tag_1" },
    { "source": "git_tag_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Digite "v1.5.2" quando solicitado. Sistema criará tag anotada.

tagMessage (string, opcional)

O que é: Mensagem descritiva da tag. Se fornecida, cria tag anotada; senão, lightweight.

Padrão: Nenhum (cria lightweight tag)

Recomendação: Use tags anotadas para releases (com mensagem)

Flow completo para testar:

{
  "name": "Teste Git Create Tag - Tag Message",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Versão",
        "parameters": {
          "variable": "version",
          "value": "2.0.0"
        }
      }
    },
    {
      "id": "variable_2",
      "type": "variable",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Data",
        "parameters": {
          "variable": "release_date",
          "value": "{{date}}"
        }
      }
    },
    {
      "id": "git_tag_1",
      "type": "git",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Create Release Tag",
        "operation": "createTag",
        "repositoryPath": "/var/www/app",
        "tagName": "v{{version}}",
        "tagMessage": "Release version {{version}} - {{release_date}}",
        "responseVariable": "tag_result"
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 900, "y": 100 },
      "data": {
        "label": "Sucesso",
        "parameters": {
          "message": "Release tag criada: {{tag_result.tagName}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 1100, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "variable_2" },
    { "source": "variable_2", "target": "git_tag_1" },
    { "source": "git_tag_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Teste: Execute o flow. Sistema criará tag anotada v2.0.0 com mensagem.

Parâmetros

Campo Tipo Obrigatório Descrição
operation string Sim Deve ser "createTag"
repositoryPath string Sim Caminho do repositório local
tagName string Sim Nome da tag (ex: v1.0.0)
tagMessage string Não Mensagem da tag (cria annotated tag)
responseVariable string Não Variável para armazenar resultado

Exemplo 1: Release Automática com Tag

Objetivo: Deploy com criação automática de tag de release

JSON para Importar

{
  "name": "Deploy com Release Tag",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "input_1",
      "type": "input",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Versão",
        "parameters": {
          "message": "Digite a versão (ex: 1.5.0):",
          "variable": "version"
        }
      }
    },
    {
      "id": "git_pull_1",
      "type": "git",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Update Code",
        "operation": "pull",
        "repositoryPath": "/var/www/production",
        "responseVariable": "pull_result"
      }
    },
    {
      "id": "git_tag_1",
      "type": "git",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Create Release Tag",
        "operation": "createTag",
        "repositoryPath": "/var/www/production",
        "tagName": "v{{version}}",
        "tagMessage": "Production release v{{version}}",
        "responseVariable": "tag_result"
      }
    },
    {
      "id": "git_push_tags_1",
      "type": "git",
      "position": { "x": 900, "y": 100 },
      "data": {
        "label": "Push Tags",
        "operation": "pushTags",
        "repositoryPath": "/var/www/production",
        "responseVariable": "push_result"
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 1100, "y": 100 },
      "data": {
        "label": "Sucesso",
        "parameters": {
          "message": "Deploy concluído!\n\nRelease: {{tag_result.tagName}}\nTag enviada ao repositório remoto"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 1300, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "input_1" },
    { "source": "input_1", "target": "git_pull_1" },
    { "source": "git_pull_1", "target": "git_tag_1" },
    { "source": "git_tag_1", "target": "git_push_tags_1" },
    { "source": "git_push_tags_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Saída esperada:

Usuário: 1.5.0
Sistema: Deploy concluído!

Release: v1.5.0
Tag enviada ao repositório remoto

Exemplo 2: Tag Baseada em Timestamp

Objetivo: Criar tag de backup com data/hora

JSON para Importar

{
  "name": "Backup Tag com Timestamp",
  "nodes": [
    {
      "id": "start_1",
      "type": "start",
      "position": { "x": 100, "y": 100 },
      "data": { "label": "Início" }
    },
    {
      "id": "variable_1",
      "type": "variable",
      "position": { "x": 300, "y": 100 },
      "data": {
        "label": "Timestamp",
        "parameters": {
          "variable": "timestamp",
          "value": "{{timestamp}}"
        }
      }
    },
    {
      "id": "git_tag_1",
      "type": "git",
      "position": { "x": 500, "y": 100 },
      "data": {
        "label": "Create Backup Tag",
        "operation": "createTag",
        "repositoryPath": "/var/www/app",
        "tagName": "backup-{{timestamp}}",
        "tagMessage": "Automated backup - {{date}}",
        "responseVariable": "tag_result"
      }
    },
    {
      "id": "message_1",
      "type": "message",
      "position": { "x": 700, "y": 100 },
      "data": {
        "label": "Confirmação",
        "parameters": {
          "message": "Tag de backup criada: {{tag_result.tagName}}"
        }
      }
    },
    {
      "id": "end_1",
      "type": "end",
      "position": { "x": 900, "y": 100 },
      "data": { "label": "Fim" }
    }
  ],
  "edges": [
    { "source": "start_1", "target": "variable_1" },
    { "source": "variable_1", "target": "git_tag_1" },
    { "source": "git_tag_1", "target": "message_1" },
    { "source": "message_1", "target": "end_1" }
  ]
}

Resposta do Node

{
  "output": "",
  "tagCreated": true,
  "tagName": "v1.5.0"
}

Boas Práticas

SIM: - Use semantic versioning (v1.2.3) - Crie tags anotadas para releases importantes - Inclua mensagem descritiva - Faça push de tags após criar - Use tags para marcar releases estáveis - Documente changelog na mensagem

NÃO: - Não crie tags com nomes genéricos - Não delete tags de produção - Não reuse nomes de tags - Não faça tag sem testar o código

Dicas

💡 Dica 1: Combine com GIT_PUSH_TAGS para enviar ao remoto

💡 Dica 2: Use variáveis para gerar nomes dinâmicos

💡 Dica 3: Tags anotadas são recomendadas para releases

💡 Dica 4: Siga semantic versioning: MAJOR.MINOR.PATCH

💡 Dica 5: Use prefixo 'v' para tags de versão (v1.0.0)

Próximo Node

GIT_PUSH_TAGS - Enviar tags ao repositório remoto → GIT_LOG - Ver commits antes de criar tag