✨ feat(ci): workflow riusabile vsix-release per le estensioni VS Code

- vsix-release.yml: controllo tag/versione, quality gate, build del .vsix e allegato alla release del tag
- examples/estensione-vscode: ci, release e maintenance da copiare nelle estensioni

Fixes #29 @1h30m
This commit is contained in:
LucaZanni committed 2026-11-27 09:59:32 +01:00
1 parent 3d28471b2c
commit b4ec52a4fe
4 files changed
+218

No files matched your search

+133
View File
@@ -0,0 +1,133 @@
name: VSIX Release
# Compila il pacchetto .vsix di un'estensione VS Code e lo allega alla release Gitea del tag.
# Va eseguito dopo auto-release.yml (needs), che crea la release.
#
# Prerequisiti nel repository chiamante:
# - package.json con script: lint:check, typecheck, format:check, build, test, package
# - lo script package produce <name>-<version>.vsix nella working-directory
# - il tag deve essere 'v' + version
on:
workflow_call:
inputs:
working-directory:
description: 'Cartella che contiene package.json, relativa alla root del repo. Default: la root.'
type: string
default: '.'
node-version:
type: string
default: '24.16.0'
jobs:
vsix-release:
runs-on: ubuntu-latest
# Il chiamante non puo' dichiararlo: su un job che usa un workflow
# riusabile timeout-minutes non e' una chiave ammessa (devops/shared-actions#23).
timeout-minutes: 30
defaults:
run:
working-directory: ${{ inputs.working-directory || '.' }}
steps:
- name: Checkout
timeout-minutes: 10
uses: https://gitea.pzetatouch.it/actions/checkout@v7
with:
token: ${{ gitea.token }}
# Prima di installare: un tag disallineato produrrebbe un .vsix con un'altra versione.
- name: Check tag version
shell: bash
run: |
set -euo pipefail
TAG=${GITHUB_REF#refs/tags/}
VERSION=$(jq -r '.version' package.json)
if [ "$TAG" != "v$VERSION" ]; then
echo "::error::Il tag $TAG non corrisponde alla versione $VERSION di package.json (atteso v$VERSION)."
exit 1
fi
- name: Setup Node.js
timeout-minutes: 10
uses: https://gitea.pzetatouch.it/actions/setup-node@v7
with:
node-version: ${{ inputs.node-version || '24.16.0' }}
# La cache npm resta allo step actions/cache: dalla v5 setup-node la accende
# da solo se package.json ha packageManager, e la duplicherebbe.
package-manager-cache: false
- name: Cache npm
timeout-minutes: 10
uses: https://gitea.pzetatouch.it/actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Configure npm private registry
run: |
echo "@pzeta:registry=https://gitea.pzetatouch.it/api/packages/PZeta_Touch/npm/" >> ~/.npmrc
echo "//gitea.pzetatouch.it/api/packages/PZeta_Touch/npm/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: Install dependencies
timeout-minutes: 15
run: npm ci
- name: Lint
run: npm run lint:check
- name: Type check
run: npm run typecheck
- name: Format check
run: npm run format:check
- name: Build
timeout-minutes: 15
run: npm run build
- name: Test
timeout-minutes: 20
run: npm run test
- name: Package VSIX
timeout-minutes: 10
run: npm run package
- name: Attach VSIX to release
timeout-minutes: 10
shell: bash
env:
GITEA_TOKEN: ${{ gitea.token }}
SERVER_URL: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
TAG=${GITHUB_REF#refs/tags/}
VSIX="$(jq -r '.name' package.json)-$(jq -r '.version' package.json).vsix"
API="$SERVER_URL/api/v1/repos/$REPOSITORY"
if [ ! -f "$VSIX" ]; then
echo "::error::Lo script package non ha prodotto $VSIX."
exit 1
fi
if ! RELEASE=$(curl -sS --fail-with-body --max-time 60 \
-H "Authorization: token $GITEA_TOKEN" "$API/releases/tags/$TAG"); then
echo "::error::Release del tag $TAG non trovata: $RELEASE"
exit 1
fi
# Rieseguendo il job, o se l'allegato e' stato caricato a mano, non si sovrascrive.
if echo "$RELEASE" | jq -e --arg name "$VSIX" 'any(.assets[]?; .name == $name)' > /dev/null; then
echo "::notice::$VSIX e' gia' allegato alla release $TAG: nessun caricamento."
exit 0
fi
ID=$(echo "$RELEASE" | jq -r '.id')
curl -sS --fail-with-body --max-time 300 -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$VSIX" \
"$API/releases/$ID/assets?name=$VSIX" > /dev/null
echo "$VSIX allegato alla release $TAG."
+23
View File
@@ -0,0 +1,23 @@
# Copia in: .gitea/workflows/ci.yml
# Usato da: estensioni VS Code
#
# Prerequisiti:
# - package.json con script: lint:check, typecheck, format:check, build, test
name: CI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
- 'docs/**'
pull_request:
branches:
- main
jobs:
quality-gates:
uses: https://gitea.pzetatouch.it/devops/shared-actions/.gitea/workflows/quality-gates.yml@v1
secrets: inherit
@@ -0,0 +1,36 @@
# Copia in: .gitea/workflows/maintenance.yml
# Trigger:
# - PR merged → cleanup branch sorgente
# - Ogni lunedì 08:00 → security audit vulnerabilità (settimanale)
# - Ogni 1° del mese → controllo pacchetti obsoleti (mensile)
# - Manuale → workflow_dispatch (esegue tutti i job di manutenzione)
name: Maintenance
on:
pull_request:
types: [closed]
schedule:
- cron: '0 2 * * 3' # ogni mercoledì alle 02:00 → security audit
- cron: '0 2 1 * *' # ogni 1° del mese alle 02:00 → outdated check
workflow_dispatch:
jobs:
branch-cleanup:
if: gitea.event_name == 'pull_request' && gitea.event.pull_request.merged == true
uses: https://gitea.pzetatouch.it/devops/shared-actions/.gitea/workflows/branch-cleanup.yml@v1
secrets: inherit
dependency-audit:
if: >
gitea.event_name == 'workflow_dispatch' ||
(gitea.event_name == 'schedule' && gitea.event.schedule == '0 2 * * 3')
uses: https://gitea.pzetatouch.it/devops/shared-actions/.gitea/workflows/dependency-check.yml@v1
secrets: inherit
dependency-outdated:
if: >
gitea.event_name == 'workflow_dispatch' ||
(gitea.event_name == 'schedule' && gitea.event.schedule == '0 2 1 * *')
uses: https://gitea.pzetatouch.it/devops/shared-actions/.gitea/workflows/dependency-outdated.yml@v1
secrets: inherit
+26
View File
@@ -0,0 +1,26 @@
# Copia in: .gitea/workflows/release.yml
# Trigger: git tag v* → crea la release Gitea e le allega il pacchetto .vsix
#
# NOTA: vsix-release attende auto-release via needs, perché carica nella release già creata.
# Workaround Gitea bug #31900: token esplicito nel checkout dei workflow condivisi.
#
# Prerequisiti:
# - package.json con script: lint:check, typecheck, format:check, build, test, package
# - il tag deve essere 'v' + version di package.json
name: Release
on:
push:
tags:
- 'v*'
jobs:
auto-release:
uses: https://gitea.pzetatouch.it/devops/shared-actions/.gitea/workflows/auto-release.yml@v1
secrets: inherit
vsix-release:
needs: [auto-release]
uses: https://gitea.pzetatouch.it/devops/shared-actions/.gitea/workflows/vsix-release.yml@v1
secrets: inherit