From 0bd90ca317453646c72a00db15f2f1b1c8115067 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Mon, 9 Feb 2026 09:33:30 -0500 Subject: [PATCH] fix: push dev releases to main branch of GitHub dev repo for ArtifactHub scanning --- .gitea/workflows/release.yaml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index ca7f00d..ed683c4 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -18,7 +18,14 @@ jobs: - name: Check if release is already finalized run: | VERSION=${GITHUB_REF_NAME#v} - TARBALL_URL="https://github.com/cpfarhood/headlamp-polaris-plugin/releases/download/${GITHUB_REF_NAME}/headlamp-polaris-plugin-${VERSION}.tar.gz" + # Determine which GitHub repo to use based on version suffix + if [[ "$VERSION" == *"-dev."* ]]; then + GITHUB_REPO="cpfarhood/headlamp-polaris-plugin-dev" + else + GITHUB_REPO="cpfarhood/headlamp-polaris-plugin" + fi + echo "GITHUB_REPO=$GITHUB_REPO" >> $GITHUB_ENV + TARBALL_URL="https://github.com/${GITHUB_REPO}/releases/download/${GITHUB_REF_NAME}/headlamp-polaris-plugin-${VERSION}.tar.gz" HTTP_CODE=$(curl -sL -o /tmp/release.tar.gz -w "%{http_code}" "$TARBALL_URL" 2>/dev/null) if [ "$HTTP_CODE" = "200" ]; then ACTUAL="sha256:$(sha256sum /tmp/release.tar.gz | awk '{print $1}')" @@ -115,7 +122,7 @@ jobs: continue-on-error: true run: | [ "$SKIP_BUILD" = "true" ] && exit 0 - GH_API="https://api.github.com/repos/cpfarhood/headlamp-polaris-plugin" + GH_API="https://api.github.com/repos/${GITHUB_REPO}" # Create release or fetch existing one BODY=$(curl -s -X POST \ -H "Authorization: token ${{ secrets.GH_PAT }}" \ @@ -153,7 +160,7 @@ jobs: curl -sf -X POST \ -H "Authorization: token ${{ secrets.GH_PAT }}" \ -H "Content-Type: application/gzip" \ - "https://uploads.github.com/repos/cpfarhood/headlamp-polaris-plugin/releases/${RELEASE_ID}/assets?name=${TARBALL}" \ + "https://uploads.github.com/repos/${GITHUB_REPO}/releases/${RELEASE_ID}/assets?name=${TARBALL}" \ --data-binary "@${TARBALL}" echo "GitHub release updated with same tarball" @@ -163,15 +170,23 @@ jobs: VERSION=${GITHUB_REF_NAME#v} git config user.name "gitea-actions[bot]" git config user.email "gitea-actions[bot]@git.farh.net" - git fetch origin main - git checkout origin/main -B main + + # Determine which Gitea branch to update based on version suffix + if [[ "$VERSION" == *"-dev."* ]]; then + GITEA_BRANCH="dev/namespace-drawer" + else + GITEA_BRANCH="main" + fi + + git fetch origin ${GITEA_BRANCH} + git checkout origin/${GITEA_BRANCH} -B ${GITEA_BRANCH} sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:${CHECKSUM}|" artifacthub-pkg.yml - sed -i "s|headlamp/plugin/archive-url:.*|headlamp/plugin/archive-url: \"https://github.com/cpfarhood/headlamp-polaris-plugin/releases/download/${GITHUB_REF_NAME}/headlamp-polaris-plugin-${VERSION}.tar.gz\"|" artifacthub-pkg.yml + sed -i "s|headlamp/plugin/archive-url:.*|headlamp/plugin/archive-url: \"https://github.com/${GITHUB_REPO}/releases/download/${GITHUB_REF_NAME}/headlamp-polaris-plugin-${VERSION}.tar.gz\"|" artifacthub-pkg.yml sed -i "s|^version:.*|version: ${VERSION}|" artifacthub-pkg.yml git add artifacthub-pkg.yml git diff --cached --quiet || { git commit -m "ci: update artifact hub metadata for ${GITHUB_REF_NAME}" - git push origin main + git push origin ${GITEA_BRANCH} } # Force-move tag to the commit with correct checksum. # This triggers a new CI run, but the guard step will detect @@ -179,7 +194,8 @@ jobs: git tag -f ${GITHUB_REF_NAME} git push -f origin ${GITHUB_REF_NAME} # Also push to GitHub directly to avoid waiting for mirror sync - git remote add github https://x-access-token:${{ secrets.GH_PAT }}@github.com/cpfarhood/headlamp-polaris-plugin.git 2>/dev/null || true + # Dev versions go to main branch of dev repo, stable versions to main of main repo + git remote add github https://x-access-token:${{ secrets.GH_PAT }}@github.com/${GITHUB_REPO}.git 2>/dev/null || true git push github main 2>/dev/null || true git push -f github ${GITHUB_REF_NAME} 2>/dev/null || true echo "Tag ${GITHUB_REF_NAME} aligned with updated metadata"