From 1ed9829f58abf0526d3830831be1bdc3dc344225 Mon Sep 17 00:00:00 2001 From: Ignacio Ballesteros Date: Tue, 17 Feb 2026 23:24:05 +0100 Subject: [PATCH] ci: add CI workflow for main, fix release pipeline ordering and node version - 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 --- .gitea/workflows/ci.yml | 26 ++++++++ .gitea/workflows/release.yml | 124 +++++++++++++++++++---------------- 2 files changed, 94 insertions(+), 56 deletions(-) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..de1ad37 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -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 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index ad2c76d..7172494 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -8,6 +8,7 @@ on: jobs: build: runs-on: ubuntu-latest + if: startsWith(github.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 @@ -34,61 +35,7 @@ jobs: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - - name: Create versioned release and upload assets - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - run: | - VERSION="${{ steps.version.outputs.version }}" - TAG="${{ steps.version.outputs.tag }}" - REPO="${GITHUB_REPOSITORY}" - API_URL="${GITEA_SERVER_URL}/api/v1" - - # Create the versioned release - 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\": \"${TAG}\", - \"body\": \"Release ${TAG}\", - \"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 release. Response: ${RELEASE}" - exit 1 - fi - - echo "Created release ID: ${RELEASE_ID}" - - # Upload XPI - for XPI in .scaffold/build/*.xpi; do - [ -f "${XPI}" ] || continue - FILENAME=$(basename "${XPI}") - echo "Uploading ${FILENAME}..." - curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/octet-stream" \ - --data-binary "@${XPI}" - done - - # Upload update manifests - for JSON in .scaffold/build/update.json .scaffold/build/update-beta.json; do - [ -f "${JSON}" ] || continue - FILENAME=$(basename "${JSON}") - echo "Uploading ${FILENAME}..." - 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 "Versioned release ${TAG} published." - - - name: Upload build artifacts for next job + - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: build-output @@ -186,3 +133,68 @@ jobs: 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@v4 + with: + name: build-output + path: .scaffold/build/ + + - name: Create versioned release and upload assets + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + VERSION="${{ needs.build.outputs.version }}" + TAG="${{ needs.build.outputs.tag }}" + REPO="${GITHUB_REPOSITORY}" + API_URL="${GITEA_SERVER_URL}/api/v1" + + # Create the versioned release + 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\": \"${TAG}\", + \"body\": \"Release ${TAG}\", + \"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 release. Response: ${RELEASE}" + exit 1 + fi + + echo "Created release ID: ${RELEASE_ID}" + + # Upload XPI + for XPI in .scaffold/build/*.xpi; do + [ -f "${XPI}" ] || continue + FILENAME=$(basename "${XPI}") + echo "Uploading ${FILENAME}..." + curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary "@${XPI}" + done + + # Upload update manifests + for JSON in .scaffold/build/update.json .scaffold/build/update-beta.json; do + [ -f "${JSON}" ] || continue + FILENAME=$(basename "${JSON}") + echo "Uploading ${FILENAME}..." + 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 "Versioned release ${TAG} published."