Compare commits
10
Commits
v1.23.1
...
83dc348fff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83dc348fff | ||
|
|
5f65df64e4 | ||
|
|
e4a633e2e2 | ||
|
|
ae81260e38 | ||
|
|
04c05ca8ce | ||
|
|
0d1ce5305b | ||
|
|
a17d9c308a | ||
|
|
7121d40ed8 | ||
|
|
41b7a9e602 | ||
|
|
f35dbc126a |
@@ -13,20 +13,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 10
|
fetch-depth: 10
|
||||||
|
|
||||||
- name: Configure git
|
|
||||||
run: |
|
|
||||||
git config --global user.name "gitea-actions"
|
|
||||||
git config --global user.email "actions@git.jonathanteran.dev"
|
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version-file: ".python-version"
|
python-version-file: ".python-version"
|
||||||
|
|
||||||
- name: Install uv
|
|
||||||
uses: astral-sh/setup-uv@v8.3.2
|
|
||||||
|
|
||||||
- name: Install git-flow and bump version
|
- name: Install git-flow and bump version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
@@ -42,6 +33,9 @@ jobs:
|
|||||||
echo "should_build=false" >> $GITHUB_OUTPUT
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v8.3.2
|
||||||
|
|
||||||
- name: Build and publish
|
- name: Build and publish
|
||||||
if: steps.version.outputs.should_build == 'true'
|
if: steps.version.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ más información):
|
|||||||
- `new`: Crea una nueva rama siguiendo CB.
|
- `new`: Crea una nueva rama siguiendo CB.
|
||||||
- `commit`: Crea un commit siguiendo CC.
|
- `commit`: Crea un commit siguiendo CC.
|
||||||
- `merge`: Mergea la rama actual a una de las ramas principales.
|
- `merge`: Mergea la rama actual a una de las ramas principales.
|
||||||
- `tag`: Crea un tag sobre el ultimo merge siguiendo SemVer.
|
- `tag`: Crea un tag sobre el ultimo merge siguiendo SemVer (ver [Tag](#tag)).
|
||||||
- `release`: Prepara la rama actual para pasarse al siguiente entorno configurado.
|
- `release`: Prepara la rama actual para pasarse al siguiente entorno configurado.
|
||||||
- `branch`: Lista las ramas del repositorio, agrupadas por entorno objetivo.
|
- `branch`: Lista las ramas del repositorio, agrupadas por entorno objetivo.
|
||||||
|
|
||||||
@@ -91,6 +91,27 @@ El workflow para el cual se penso la herramienta es el siguiente:
|
|||||||
En cualquier momento se puede usar `git-flow branch` para ver en qué entorno está cada rama, y cuáles
|
En cualquier momento se puede usar `git-flow branch` para ver en qué entorno está cada rama, y cuáles
|
||||||
están todavía en progreso (`wip/`) o descartadas (`trash/`).
|
están todavía en progreso (`wip/`) o descartadas (`trash/`).
|
||||||
|
|
||||||
|
### Tag
|
||||||
|
|
||||||
|
`git-flow tag [--target=<RAMA>] [--token=<TOKEN>] [--update-changelog]`
|
||||||
|
|
||||||
|
- `--target`: rama principal sobre la que se taggea. Por defecto, la rama actual. Debe ser una de las
|
||||||
|
ramas principales configuradas.
|
||||||
|
- `--token`: Access Token del remoto. Si se pasa, se asume que corre en un pipeline: los commits y el
|
||||||
|
último tag se obtienen por API del remoto y el tag se crea en el remoto (y también localmente). Si
|
||||||
|
no, se usa `.repository-token` y todo se resuelve localmente.
|
||||||
|
- `--update-changelog`: genera la entrada correspondiente en `CHANGELOG.md` y la commitea antes de
|
||||||
|
taggear (en un pipeline, además hace push del commit).
|
||||||
|
|
||||||
|
Comportamiento:
|
||||||
|
|
||||||
|
- El tag se crea sobre el último merge (first-parent) de la rama. Si ese merge ya tiene un tag, no se
|
||||||
|
hace nada.
|
||||||
|
- La versión se calcula a partir de los tipos de commit (CC) del último merge. Si ningún commit
|
||||||
|
implica un salto de versión, se avisa y el comando termina con código de salida 1.
|
||||||
|
- Con más de un entorno configurado, cada rama versiona por separado con el nombre del entorno como
|
||||||
|
sufijo (por ejemplo, `v1.2.0-prod`). Con un solo entorno no se agrega sufijo.
|
||||||
|
|
||||||
## Remotos soportados
|
## Remotos soportados
|
||||||
|
|
||||||
Cada remoto necesita un Access Token con permisos para crear Pull/Merge Requests y tags. El token se
|
Cada remoto necesita un Access Token con permisos para crear Pull/Merge Requests y tags. El token se
|
||||||
|
|||||||
@@ -16,20 +16,15 @@ app = typer.Typer()
|
|||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def tag(token: str | None = None, update_changelog: bool = False):
|
def tag(target: str | None = None, token: str | None = None, update_changelog: bool = False):
|
||||||
"""Crea un nuevo tag para el último merge."""
|
"""Crea un nuevo tag para el último merge."""
|
||||||
base.ensure_initialized()
|
base.ensure_initialized()
|
||||||
|
|
||||||
target = Git.get_current_branch()
|
target = target or Git.get_current_branch()
|
||||||
|
|
||||||
if target not in base.environments:
|
if target not in base.environments:
|
||||||
raise GitFlowError("Solo se pueden taggear commits en ramas principales.")
|
raise GitFlowError("Solo se pueden taggear commits en ramas principales.")
|
||||||
|
|
||||||
token, ci = get_token_and_ci(token)
|
|
||||||
|
|
||||||
if ci and not token:
|
|
||||||
raise GitFlowError("No hay token disponible")
|
|
||||||
|
|
||||||
merge_commit = Git(
|
merge_commit = Git(
|
||||||
"log", first_parent=True, merges=True, max_count=1, format="%H"
|
"log", first_parent=True, merges=True, max_count=1, format="%H"
|
||||||
).firstline()
|
).firstline()
|
||||||
@@ -37,6 +32,19 @@ def tag(token: str | None = None, update_changelog: bool = False):
|
|||||||
if not merge_commit:
|
if not merge_commit:
|
||||||
raise GitFlowError("No hay merges a taggear.")
|
raise GitFlowError("No hay merges a taggear.")
|
||||||
|
|
||||||
|
merge_commit_tag = Git("tag", "--points-at", merge_commit).firstline()
|
||||||
|
if merge_commit_tag:
|
||||||
|
base.io_info(f"El último merge ya tiene un tag: {merge_commit_tag}")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Con varios entornos cada uno versiona por separado (v1.0.0-prod), con uno solo no hace falta
|
||||||
|
suffix = f"-{target}" if len(base.environments) > 1 else ""
|
||||||
|
|
||||||
|
token, ci = get_token_and_ci(token)
|
||||||
|
|
||||||
|
if ci and not token:
|
||||||
|
raise GitFlowError("No hay token disponible")
|
||||||
|
|
||||||
# Con varios entornos cada uno versiona por separado (v1.0.0-prod), con uno solo no hace falta
|
# Con varios entornos cada uno versiona por separado (v1.0.0-prod), con uno solo no hace falta
|
||||||
suffix = f"-{target}" if len(base.environments) > 1 else ""
|
suffix = f"-{target}" if len(base.environments) > 1 else ""
|
||||||
|
|
||||||
@@ -48,7 +56,7 @@ def tag(token: str | None = None, update_changelog: bool = False):
|
|||||||
current_tag = base.get_remote_api(token).get_latest_tag(suffix)
|
current_tag = base.get_remote_api(token).get_latest_tag(suffix)
|
||||||
else:
|
else:
|
||||||
# Commits se obtienen del último merge, listando hasta el primer forkpoint
|
# Commits se obtienen del último merge, listando hasta el primer forkpoint
|
||||||
branch = Git("show", merge_commit + "^2", patch=False, format="%h").firstline()
|
branch = Git("show", merge_commit + "^2", patch=False, format="%H").firstline()
|
||||||
fork_point = Git.get_first_fork_point(branch, target)
|
fork_point = Git.get_first_fork_point(branch, target)
|
||||||
commits = Git.get_commits(fork_point, branch)
|
commits = Git.get_commits(fork_point, branch)
|
||||||
# Último tag se obtiene localmente
|
# Último tag se obtiene localmente
|
||||||
@@ -74,7 +82,7 @@ def tag(token: str | None = None, update_changelog: bool = False):
|
|||||||
if ci:
|
if ci:
|
||||||
Git("push").exec()
|
Git("push").exec()
|
||||||
|
|
||||||
tag_commit = Git("show", "HEAD", patch=False, format="%h").firstline()
|
tag_commit = Git("show", "HEAD", patch=False, format="%H").firstline()
|
||||||
|
|
||||||
if ci:
|
if ci:
|
||||||
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
|
base.io_success(base.get_remote_api(token).create_tag(next_tag, tag_commit))
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class GitlabRemoteAPI(RemoteAPI):
|
|||||||
if response.ok:
|
if response.ok:
|
||||||
return "Tag creado exitosamente: " + tag
|
return "Tag creado exitosamente: " + tag
|
||||||
else:
|
else:
|
||||||
raise GitFlowError("Ocurrió un error al crear el tag para repositorio " + quote(self.repository, safe="") + ": " + response.text)
|
raise GitFlowError("Ocurrió un error al crear el tag: " + response.text)
|
||||||
|
|
||||||
def get_merge_commits(self, merge_commit: str) -> list[Commit]:
|
def get_merge_commits(self, merge_commit: str) -> list[Commit]:
|
||||||
mrs = self.get_json(
|
mrs = self.get_json(
|
||||||
|
|||||||
Reference in New Issue
Block a user