Compare commits
6
Commits
98f71d5481
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
456af932a4 | ||
|
|
eed5b606fb | ||
|
|
14ec438fa1 | ||
|
|
98d5c4ab3d | ||
|
|
5cff0e4484 | ||
|
|
61712b0872 |
@@ -22,12 +22,22 @@ jobs:
|
|||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
pip install git-flow-envs=="${{ vars.GITFLOWENVS_VERSION }}"
|
pip install git-flow-envs=="${{ vars.GITFLOWENVS_VERSION }}"
|
||||||
git-flow tag --token="${{ secrets.GITEA_TOKEN }}"
|
# El código 3 indica que no hace falta un nuevo tag: se saltea la publicación
|
||||||
|
status=0
|
||||||
|
git-flow tag --token="${{ secrets.GITEA_TOKEN }}" || status=$?
|
||||||
|
|
||||||
|
if [ "$status" -eq 3 ]; then
|
||||||
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
|
elif [ "$status" -ne 0 ]; then
|
||||||
|
exit "$status"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Install uv
|
- name: Install uv
|
||||||
|
if: steps.version.outputs.skip != 'true'
|
||||||
uses: astral-sh/setup-uv@v8.3.2
|
uses: astral-sh/setup-uv@v8.3.2
|
||||||
|
|
||||||
- name: Build and publish
|
- name: Build and publish
|
||||||
|
if: steps.version.outputs.skip != 'true'
|
||||||
run: |
|
run: |
|
||||||
uv build
|
uv build
|
||||||
uv publish --token="${{ secrets.PYPI_TOKEN }}"
|
uv publish --token="${{ secrets.PYPI_TOKEN }}"
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
image: python:3.10
|
|
||||||
|
|
||||||
pipelines:
|
|
||||||
branches:
|
|
||||||
'main':
|
|
||||||
- step:
|
|
||||||
name: "Tag and publish package"
|
|
||||||
caches:
|
|
||||||
- pip
|
|
||||||
script:
|
|
||||||
- pip install uv
|
|
||||||
- uv run git-flow tag --token=$BEARER
|
|
||||||
- uv build
|
|
||||||
- uv publish --token=$PYPI_TOKEN
|
|
||||||
@@ -75,15 +75,12 @@ def show_commits_to_merge(target):
|
|||||||
|
|
||||||
|
|
||||||
def check_merge_conflicts(target: str):
|
def check_merge_conflicts(target: str):
|
||||||
merge_conflicts = Git("merge", target, ff=False, commit=False).code(
|
merge_conflicts = Git.get_merge_conflicts(target, print="Verificando conflictos de merge")
|
||||||
print="Realizando merge de prueba para verificar conflictos"
|
|
||||||
)
|
|
||||||
|
|
||||||
Git("merge", abort=True).exec(print="Abortando merge de prueba", check=False)
|
|
||||||
|
|
||||||
if merge_conflicts:
|
if merge_conflicts:
|
||||||
|
files = "\n".join(" - " + file for file in merge_conflicts)
|
||||||
base.io_error(
|
base.io_error(
|
||||||
f"La rama actual tiene conflictos con {target}.\n"
|
f"La rama actual tiene conflictos con {target}:\n{files}\n\n"
|
||||||
f"Se recomienda mergear {target} a la rama actual, resolver los conflictos localmente,\n"
|
f"Se recomienda mergear {target} a la rama actual, resolver los conflictos localmente,\n"
|
||||||
"y ejecutar nuevamente este comando",
|
"y ejecutar nuevamente este comando",
|
||||||
title="Conflictos de merge",
|
title="Conflictos de merge",
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ from git_flow.git import Git
|
|||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
|
||||||
|
# Código de salida cuando no hace falta crear un tag, para que el CI pueda saltear la publicación
|
||||||
|
EXIT_NO_TAG_NEEDED = 3
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def tag(target: str | None = None, token: str | None = None, update_changelog: bool = False):
|
def tag(target: str | None = None, token: str | None = None, update_changelog: bool = False):
|
||||||
@@ -35,7 +38,7 @@ def tag(target: str | None = None, token: str | None = None, update_changelog: b
|
|||||||
merge_commit_tag = Git("tag", "--points-at", merge_commit).firstline()
|
merge_commit_tag = Git("tag", "--points-at", merge_commit).firstline()
|
||||||
if merge_commit_tag:
|
if merge_commit_tag:
|
||||||
base.io_info(f"El último merge ya tiene un tag: {merge_commit_tag}")
|
base.io_info(f"El último merge ya tiene un tag: {merge_commit_tag}")
|
||||||
return
|
raise typer.Exit(code=EXIT_NO_TAG_NEEDED)
|
||||||
|
|
||||||
token, ci = get_token_and_ci(token)
|
token, ci = get_token_and_ci(token)
|
||||||
|
|
||||||
@@ -97,7 +100,7 @@ def tag(target: str | None = None, token: str | None = None, update_changelog: b
|
|||||||
"Los cambios realizados no implican un salto de versión, se mantiene la anterior."
|
"Los cambios realizados no implican un salto de versión, se mantiene la anterior."
|
||||||
)
|
)
|
||||||
|
|
||||||
raise typer.Exit(code=1)
|
raise typer.Exit(code=EXIT_NO_TAG_NEEDED)
|
||||||
|
|
||||||
if update_changelog:
|
if update_changelog:
|
||||||
changelog = Changelog()
|
changelog = Changelog()
|
||||||
|
|||||||
@@ -63,6 +63,21 @@ class Git:
|
|||||||
def get_branches(prefix: str = ""):
|
def get_branches(prefix: str = ""):
|
||||||
return Git._get_references("heads/" + prefix)
|
return Git._get_references("heads/" + prefix)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_merge_conflicts(target: str, print: str | None = None) -> list[str]:
|
||||||
|
"""Archivos con conflictos al mergear target en HEAD. El merge se resuelve en memoria con
|
||||||
|
merge-tree, sin tocar el índice ni el worktree."""
|
||||||
|
process = Git(
|
||||||
|
"merge-tree", "HEAD", target, write_tree=True, name_only=True, messages=False
|
||||||
|
)._get(print, check=False)
|
||||||
|
|
||||||
|
# 0: sin conflictos, 1: con conflictos, otro: error (por ejemplo, historias sin relación)
|
||||||
|
if process.returncode not in (0, 1):
|
||||||
|
process.check_returncode()
|
||||||
|
|
||||||
|
# Primera línea: OID del árbol resultante, luego los archivos en conflicto
|
||||||
|
return [l for l in process.stdout.splitlines()[1:] if l]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def status():
|
def status():
|
||||||
return list(map(Git.Status, Git("status", porcelain=True).lines(False)))
|
return list(map(Git.Status, Git("status", porcelain=True).lines(False)))
|
||||||
|
|||||||
Reference in New Issue
Block a user