fix: remove GitHub Actions workflow and handle existing release assets

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 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 09:02:19 -05:00
parent 8941f9ac16
commit 2dabb1c731
2 changed files with 27 additions and 63 deletions
+27 -7
View File
@@ -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" \
-56
View File
@@ -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