5 Commits

Author SHA1 Message Date
Ignacio Ballesteros
2768eb39de fix: correct Gitea Actions release workflow
All checks were successful
CI / build (push) Successful in 20s
Release / build (push) Successful in 26s
Release / update-rolling-release (push) Successful in 7s
Release / publish-release (push) Successful in 7s
- Use gitea.ref/server_url/repository context vars instead of GitHub env vars
- Move API_URL and REPO into env: block so context expressions are evaluated
- Pass gitea.ref via env: for version extraction (GITEA_REF)
- Replace grep/cut JSON parsing with jq throughout
- Fix tag creation body: use 'target' key instead of 'message'
- Add set -euo pipefail and diagnostic echo output to both run blocks
- Add null check on jq-parsed RELEASE_ID in publish-release
2026-02-17 23:50:08 +01:00
Ignacio Ballesteros
30f2b4f810 fix: use gitea.token instead of missing GITEA_TOKEN secret
Some checks failed
CI / build (push) Successful in 20s
Release / build (push) Successful in 25s
Release / update-rolling-release (push) Failing after 17s
Release / publish-release (push) Has been skipped
2026-02-17 23:33:53 +01:00
Ignacio Ballesteros
f47a203a80 fix: downgrade artifact actions to v3 for Gitea GHES compatibility
Some checks failed
CI / build (push) Successful in 36s
Release / build (push) Successful in 38s
Release / update-rolling-release (push) Failing after 17s
Release / publish-release (push) Has been skipped
2026-02-17 23:30:00 +01:00
Ignacio Ballesteros
1ed9829f58 ci: add CI workflow for main, fix release pipeline ordering and node version
Some checks failed
CI / build (push) Successful in 45s
Release / build (push) Failing after 22s
Release / update-rolling-release (push) Has been skipped
Release / publish-release (push) Has been skipped
- Add ci.yml to build on every push to main (Node 22)
- Add job-level guard on release build job (startsWith refs/tags/v)
- Bump Node to 22 in release.yml to satisfy zotero-plugin-scaffold >=22.8.0
- Extract publish-release as a third job (needs: [build, update-rolling-release])
  so the versioned release and XPI are only published after the full pipeline succeeds
2026-02-17 23:24:05 +01:00
Ignacio Ballesteros
e836809fc0 fix: use GITEA_SERVER_URL instead of GITHUB_SERVER_URL in release workflow 2026-02-17 23:03:27 +01:00
2 changed files with 164 additions and 109 deletions

26
.gitea/workflows/ci.yml Normal file
View File

@@ -0,0 +1,26 @@
name: CI
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build

View File

@@ -8,6 +8,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: startsWith(gitea.ref, 'refs/tags/v')
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
@@ -19,7 +20,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "22"
cache: "npm"
- name: Install dependencies
@@ -30,18 +31,145 @@ jobs:
- name: Get version
id: version
env:
GITEA_REF: ${{ gitea.ref }}
run: |
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "version=${GITEA_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "tag=${GITEA_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-output
path: .scaffold/build/
retention-days: 1
update-rolling-release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: .scaffold/build/
- name: Upsert rolling 'release' tag with latest update.json
env:
GITEA_TOKEN: ${{ gitea.token }}
API_URL: ${{ gitea.server_url }}/api/v1
REPO: ${{ gitea.repository }}
VERSION: ${{ needs.build.outputs.version }}
run: |
set -euo pipefail
TAG="release"
echo "=== Configuration ==="
echo "API_URL: ${API_URL}"
echo "REPO: ${REPO}"
echo "VERSION: ${VERSION}"
# Check if the rolling release already exists
EXISTING=$(curl -s -o /dev/null -w "%{http_code}" \
"${API_URL}/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${GITEA_TOKEN}")
echo "Existing release check: HTTP ${EXISTING}"
if [ "${EXISTING}" = "200" ]; then
# Fetch the release ID
RELEASE_ID=$(curl -s "${API_URL}/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${GITEA_TOKEN}" \
| jq -r '.id')
echo "Found existing 'release' release (ID: ${RELEASE_ID}). Replacing assets..."
# Delete all existing assets so we can upload fresh ones
ASSETS=$(curl -s "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${GITEA_TOKEN}")
echo "${ASSETS}" | jq -r '.[].id' | while read -r ASSET_ID; do
echo "Deleting asset ${ASSET_ID}..."
curl -s -X DELETE "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}" \
-H "Authorization: token ${GITEA_TOKEN}"
done
# Update the release body to reflect the current version
curl -s -X PATCH "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"Rolling release — always points to the latest update manifest (currently v${VERSION}). Do not delete.\"}"
else
# Create the rolling release for the first time
echo "Creating new 'release' release..."
# Ensure the tag exists (Gitea requires the tag to exist before creating a release for it)
curl -s -X POST "${API_URL}/repos/${REPO}/tags" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"target\": \"main\"}" || true
RELEASE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${TAG}\",
\"name\": \"Update Manifest (rolling)\",
\"body\": \"Rolling release — always points to the latest update manifest (currently v${VERSION}). Do not delete.\",
\"draft\": false,
\"prerelease\": false
}")
RELEASE_ID=$(echo "${RELEASE}" | jq -r '.id')
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
echo "Failed to create rolling release. Response: ${RELEASE}"
exit 1
fi
echo "Created rolling release ID: ${RELEASE_ID}"
fi
# Upload update.json and update-beta.json to the rolling release
for JSON in .scaffold/build/update.json .scaffold/build/update-beta.json; do
[ -f "${JSON}" ] || continue
FILENAME=$(basename "${JSON}")
echo "Uploading ${FILENAME} to rolling release..."
curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
--data-binary "@${JSON}"
done
echo "Rolling 'release' release updated to v${VERSION}."
publish-release:
runs-on: ubuntu-latest
needs: [build, update-rolling-release]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: .scaffold/build/
- name: Create versioned release and upload assets
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_TOKEN: ${{ gitea.token }}
API_URL: ${{ gitea.server_url }}/api/v1
REPO: ${{ gitea.repository }}
VERSION: ${{ needs.build.outputs.version }}
TAG: ${{ needs.build.outputs.tag }}
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="${{ steps.version.outputs.tag }}"
REPO="${GITHUB_REPOSITORY}"
API_URL="${GITHUB_SERVER_URL}/api/v1"
set -euo pipefail
echo "=== Configuration ==="
echo "API_URL: ${API_URL}"
echo "REPO: ${REPO}"
echo "VERSION: ${VERSION}"
echo "TAG: ${TAG}"
# Create the versioned release
RELEASE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \
@@ -55,9 +183,9 @@ jobs:
\"prerelease\": false
}")
RELEASE_ID=$(echo "${RELEASE}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
RELEASE_ID=$(echo "${RELEASE}" | jq -r '.id')
if [ -z "${RELEASE_ID}" ]; then
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
echo "Failed to create release. Response: ${RELEASE}"
exit 1
fi
@@ -87,102 +215,3 @@ jobs:
done
echo "Versioned release ${TAG} published."
- name: Upload build artifacts for next job
uses: actions/upload-artifact@v4
with:
name: build-output
path: .scaffold/build/
retention-days: 1
update-rolling-release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: .scaffold/build/
- name: Upsert rolling 'release' tag with latest update.json
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
TAG="release"
REPO="${GITHUB_REPOSITORY}"
API_URL="${GITHUB_SERVER_URL}/api/v1"
VERSION="${{ needs.build.outputs.version }}"
# Check if the rolling release already exists
EXISTING=$(curl -s -o /dev/null -w "%{http_code}" \
"${API_URL}/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${GITEA_TOKEN}")
if [ "${EXISTING}" = "200" ]; then
# Fetch the release ID
RELEASE_ID=$(curl -s "${API_URL}/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${GITEA_TOKEN}" \
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
echo "Found existing 'release' release (ID: ${RELEASE_ID}). Replacing assets..."
# Delete all existing assets so we can upload fresh ones
ASSETS=$(curl -s "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${GITEA_TOKEN}")
echo "${ASSETS}" | grep -o '"id":[0-9]*' | cut -d: -f2 | while read ASSET_ID; do
echo "Deleting asset ${ASSET_ID}..."
curl -s -X DELETE "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}" \
-H "Authorization: token ${GITEA_TOKEN}"
done
# Update the release body to reflect the current version
curl -s -X PATCH "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"Rolling release — always points to the latest update manifest (currently v${VERSION}). Do not delete.\"}"
else
# Create the rolling release for the first time
echo "Creating new 'release' release..."
# Ensure the tag exists (Gitea requires the tag to exist before creating a release for it)
curl -s -X POST "${API_URL}/repos/${REPO}/tags" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"message\": \"Rolling release tag for update.json hosting\"}" || true
RELEASE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${TAG}\",
\"name\": \"Update Manifest (rolling)\",
\"body\": \"Rolling release — always points to the latest update manifest (currently v${VERSION}). Do not delete.\",
\"draft\": false,
\"prerelease\": false
}")
RELEASE_ID=$(echo "${RELEASE}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -z "${RELEASE_ID}" ]; then
echo "Failed to create rolling release. Response: ${RELEASE}"
exit 1
fi
echo "Created rolling release ID: ${RELEASE_ID}"
fi
# Upload update.json and update-beta.json to the rolling release
for JSON in .scaffold/build/update.json .scaffold/build/update-beta.json; do
[ -f "${JSON}" ] || continue
FILENAME=$(basename "${JSON}")
echo "Uploading ${FILENAME} to rolling release..."
curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
--data-binary "@${JSON}"
done
echo "Rolling 'release' release updated to v${VERSION}."