From 1c37a518aa32353183261092f3729404928107af Mon Sep 17 00:00:00 2001 From: mendozagit Date: Fri, 23 Oct 2026 09:08:33 -0600 Subject: [PATCH] =?UTF-8?q?ci(release):=20tomar=20la=20versi=C3=B3n=20de?= =?UTF-8?q?=20FiscalApi.Cli.csproj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El workflow de release pedía la versión en un input manual y la pasaba a dotnet publish con -p:Version. Ahora la versión sale de en src/FiscalApi.Cli/FiscalApi.Cli.csproj, que es la misma que el CLI reporta en --version. - Se quita el input "version" de workflow_dispatch. - El job version lee del csproj y falla si no es semántica. - Un tag v debe coincidir con ; si no, el job falla. - Ya no se sobrescribe la versión al publicar, en release.yml ni en publish-linux.sh. El paso de smoke test sigue comparando --version con la versión del csproj. --- .github/scripts/publish-linux.sh | 2 +- .github/workflows/release.yml | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/scripts/publish-linux.sh b/.github/scripts/publish-linux.sh index a2dc630..6b21bde 100644 --- a/.github/scripts/publish-linux.sh +++ b/.github/scripts/publish-linux.sh @@ -21,7 +21,7 @@ curl -fsSL --retry 3 https://dot.net/v1/dotnet-install.sig -o /tmp/dotnet-instal bash "$(dirname "${BASH_SOURCE[0]}")/verify-dotnet-install.sh" /tmp/dotnet-install.sh /tmp/dotnet-install.sig bash /tmp/dotnet-install.sh --jsonfile global.json --install-dir "$DOTNET_ROOT" --no-path -dotnet publish src/FiscalApi.Cli -c Release -r linux-x64 -p:Version="$version" -o "$output" +dotnet publish src/FiscalApi.Cli -c Release -r linux-x64 -o "$output" binary="$output/fiscalapi" required_glibc=$(objdump -T "$binary" | grep -oE 'GLIBC_[0-9]+(\.[0-9]+)+' | sed 's/^GLIBC_//' | sort -uV | tail -n 1) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 495f899..0d88a6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,11 +5,6 @@ on: tags: - "v*" workflow_dispatch: - inputs: - version: - description: "Versión semántica sin la v (p. ej. 0.1.0-rc.1). El borrador se crea con el tag v sobre el commit elegido." - required: true - type: string permissions: contents: read @@ -32,26 +27,31 @@ jobs: tag: ${{ steps.version.outputs.tag }} prerelease: ${{ steps.version.outputs.prerelease }} steps: + - name: Checkout + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 + with: + persist-credentials: false + - name: Resolve version id: version env: REF_TYPE: ${{ github.ref_type }} REF_NAME: ${{ github.ref_name }} - INPUT_VERSION: ${{ inputs.version }} run: | - if [ "$REF_TYPE" = "tag" ]; then - version="${REF_NAME#v}" - else - version="$INPUT_VERSION" + csproj=src/FiscalApi.Cli/FiscalApi.Cli.csproj + if [ "$(grep -c '' "$csproj")" -ne 1 ]; then + echo "::error::$csproj debe declarar exactamente un ." + exit 1 fi + version=$(sed -nE 's|.*([^<]+).*|\1|p' "$csproj") identifier='(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)' semver="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-${identifier}(\.${identifier})*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$" if ! [[ "$version" =~ $semver ]]; then - echo "::error::La versión del tag o de la entrada 'version' no es semántica (p. ej. v1.2.3 o 1.2.3-rc.1)." + echo "::error:: de $csproj ('$version') no es semántica (p. ej. 1.2.3 o 1.2.3-rc.1)." exit 1 fi - if [ "$REF_TYPE" = "tag" ] && [ -n "$INPUT_VERSION" ] && [ "$INPUT_VERSION" != "$version" ]; then - echo "::error::La entrada 'version' no coincide con el tag v$version; déjala igual a $version o corre sobre una rama." + if [ "$REF_TYPE" = "tag" ] && [ "${REF_NAME#v}" != "$version" ]; then + echo "::error::El tag $REF_NAME no coincide con $version de $csproj." exit 1 fi without_build="${version%%+*}" @@ -70,7 +70,7 @@ jobs: TAG: v${{ steps.version.outputs.version }} run: | if output=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG" --jq .ref 2>&1); then - echo "::error::El tag $TAG ya existe. Usa otra versión o empuja el tag para un release real." + echo "::error::El tag $TAG ya existe. Sube en src/FiscalApi.Cli/FiscalApi.Cli.csproj antes de publicar." exit 1 fi if [[ "$output" != *"HTTP 404"* ]]; then @@ -160,7 +160,7 @@ jobs: docker run --rm -v "$GITHUB_WORKSPACE:/src" -w /src "$LINUX_BUILD_IMAGE" \ bash .github/scripts/publish-linux.sh "$VERSION" "$PUBLISH_DIR" else - dotnet publish src/FiscalApi.Cli -c Release -r "$RID" -p:Version="$VERSION" -o "$PUBLISH_DIR" + dotnet publish src/FiscalApi.Cli -c Release -r "$RID" -o "$PUBLISH_DIR" fi - name: Smoke test