From 2dabb1c7319f23d9f4dcf62734c72a094717f6a2 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Fri, 6 Feb 2026 09:02:19 -0500 Subject: [PATCH] fix: remove GitHub Actions workflow and handle existing release assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GitHub Actions fallback workflow raced with the Gitea CI — it ran first and created the GitHub release with its own tarball (different checksum), causing the Gitea CI's upload to fail and leaving a checksum mismatch on Artifact Hub. - Remove .github/workflows/release.yml entirely (Gitea CI handles both Gitea and GitHub releases) - Fix the Gitea CI's GitHub release step to delete existing assets before uploading, so re-runs and race conditions are handled gracefully Co-Authored-By: Claude Opus 4.6 --- .gitea/workflows/release.yaml | 34 ++++++++++++++++----- .github/workflows/release.yml | 56 ----------------------------------- 2 files changed, 27 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 3df1682..04188e6 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -70,22 +70,42 @@ jobs: - name: Create GitHub release continue-on-error: true run: | - RELEASE_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ + GH_API="https://api.github.com/repos/cpfarhood/polaris-headlamp-plugin" + AUTH="-H \"Authorization: token ${{ secrets.GH_PAT }}\"" + # Create release or fetch existing one + BODY=$(curl -s -X POST \ -H "Authorization: token ${{ secrets.GH_PAT }}" \ -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/cpfarhood/polaris-headlamp-plugin/releases" \ + "${GH_API}/releases" \ -d "{\"tag_name\":\"${GITHUB_REF_NAME}\",\"name\":\"${GITHUB_REF_NAME}\",\"generate_release_notes\":true}") - HTTP_CODE=$(echo "$RELEASE_RESPONSE" | tail -1) - BODY=$(echo "$RELEASE_RESPONSE" | sed '$d') - if [ "$HTTP_CODE" = "422" ]; then + RELEASE_ID=$(echo "$BODY" | node -e "process.stdin.resume();let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>console.log(JSON.parse(d).id))") + if [ "$RELEASE_ID" = "undefined" ]; then echo "Release already exists, fetching it..." BODY=$(curl -sf \ -H "Authorization: token ${{ secrets.GH_PAT }}" \ -H "Accept: application/vnd.github+json" \ - "https://api.github.com/repos/cpfarhood/polaris-headlamp-plugin/releases/tags/${GITHUB_REF_NAME}") + "${GH_API}/releases/tags/${GITHUB_REF_NAME}") + RELEASE_ID=$(echo "$BODY" | node -e "process.stdin.resume();let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>console.log(JSON.parse(d).id))") fi - RELEASE_ID=$(echo "$BODY" | node -e "process.stdin.resume();let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>console.log(JSON.parse(d).id))") echo "Release ID: $RELEASE_ID" + # Delete any existing assets with the same name + ASSETS=$(curl -sf \ + -H "Authorization: token ${{ secrets.GH_PAT }}" \ + -H "Accept: application/vnd.github+json" \ + "${GH_API}/releases/${RELEASE_ID}/assets") + echo "$ASSETS" | node -e " + process.stdin.resume();let d=''; + process.stdin.on('data',c=>d+=c); + process.stdin.on('end',()=>{ + const assets=JSON.parse(d); + assets.filter(a=>a.name==='${TARBALL}').forEach(a=>console.log(a.id)); + })" | while read -r ASSET_ID; do + echo "Deleting existing asset $ASSET_ID..." + curl -sf -X DELETE \ + -H "Authorization: token ${{ secrets.GH_PAT }}" \ + "${GH_API}/releases/assets/${ASSET_ID}" + done + # Upload tarball curl -sf -X POST \ -H "Authorization: token ${{ secrets.GH_PAT }}" \ -H "Content-Type: application/gzip" \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index a96e898..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: GitHub Release (fallback) - -on: - push: - tags: - - 'v*' - -permissions: - contents: write - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Check if release already exists - id: check - run: | - if gh release view "${{ github.ref_name }}" --repo "${{ github.repository }}" &>/dev/null; then - echo "Release ${{ github.ref_name }} already exists (created by Gitea CI), skipping." - echo "exists=true" >> "$GITHUB_OUTPUT" - else - echo "No existing release found, building as fallback." - echo "exists=false" >> "$GITHUB_OUTPUT" - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Checkout - if: steps.check.outputs.exists == 'false' - uses: actions/checkout@v4 - - - name: Setup Node.js - if: steps.check.outputs.exists == 'false' - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - - - name: Install dependencies - if: steps.check.outputs.exists == 'false' - run: npm ci - - - name: Build plugin - if: steps.check.outputs.exists == 'false' - run: npx @kinvolk/headlamp-plugin build - - - name: Package tarball - if: steps.check.outputs.exists == 'false' - run: npx @kinvolk/headlamp-plugin package - - - name: Create GitHub Release - if: steps.check.outputs.exists == 'false' - uses: softprops/action-gh-release@v2 - with: - files: "*.tar.gz" - generate_release_notes: true