Skip to content

Commit cfe6f66

Browse files
committed
fix: fetch latest version from GitHub Releases API instead of local git tags
1 parent 761725f commit cfe6f66

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

scripts/aur-publish.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,25 @@ done
120120
section "Versão"
121121

122122
if [[ -z "$VERSION" ]]; then
123-
cd "$REPO_ROOT"
124-
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || true)
123+
info "Buscando" "última release em github.com/${GITHUB_REPO}..."
124+
125+
LATEST_JSON="$WORK_DIR/latest_release.json"
126+
HTTP_CODE=$(curl -sL -w "%{http_code}" \
127+
-H "Accept: application/vnd.github+json" \
128+
-o "$LATEST_JSON" \
129+
"https://api.github.com/repos/${GITHUB_REPO}/releases/latest")
130+
131+
if [[ "$HTTP_CODE" != "200" ]]; then
132+
die "GitHub API retornou HTTP $HTTP_CODE. Verifique se o repositório tem releases publicadas."
133+
fi
134+
135+
VERSION=$(grep '"tag_name"' "$LATEST_JSON" | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' | sed 's/^v//')
136+
125137
if [[ -z "$VERSION" ]]; then
126-
die "Nenhuma tag encontrada. Use --version <x.y.z> para especificar a versão."
138+
die "Não foi possível extrair a versão da API do GitHub. Use --version <x.y.z>."
127139
fi
128-
info "Detectada" "v${VERSION} (última tag git)"
140+
141+
info "Detectada" "v${VERSION} (última release no GitHub)"
129142
else
130143
VERSION="${VERSION#v}"
131144
info "Especificada" "v${VERSION}"

0 commit comments

Comments
 (0)