From b864af4bb24f1e06f24743bab8925f526000cdaa Mon Sep 17 00:00:00 2001 From: LucaZanni Date: Thu, 26 Mar 2026 14:41:36 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat(ci):=20aggiungi=20versionam?= =?UTF-8?q?ento=20semantico=20per=20shared-actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Aggiunto package.json con versione 1.0.0 - Nuovo workflow release.yml standalone: crea release Gitea su tag v* - Aggiornamento automatico tag major floating (v1 → latest v1.x.x) - Esempi aggiornati da @main a @v1 (tag major stabile) Flusso di release: git tag v1.0.0 && git push origin v1.0.0 → crea release Gitea con changelog → aggiorna tag floating v1 --- .gitea/workflows/release.yml | 86 ++++++++++++++++++++++++++ examples/capacitor/ci.yml | 4 +- examples/capacitor/maintenance.yml | 4 +- examples/capacitor/release.yml | 6 +- examples/libreria-npm/ci.yml | 2 +- examples/libreria-npm/maintenance.yml | 4 +- examples/libreria-npm/release.yml | 4 +- examples/microservizio/ci.yml | 2 +- examples/microservizio/maintenance.yml | 4 +- examples/microservizio/release.yml | 4 +- package.json | 6 ++ 11 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 .gitea/workflows/release.yml create mode 100644 package.json diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..b2fa591 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,86 @@ +name: Release + +# Workflow standalone — gira nel repo shared-actions stesso. +# Trigger: git tag v* (es. v1.0.0, v1.1.0) +# +# Uso: +# git tag v1.0.0 +# git push origin v1.0.0 +# +# I consumer dei workflow riutilizzabili possono poi usare: +# uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@v1.0.0 +# oppure il tag major floating (aggiornato ad ogni release): +# uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@v1 + +on: + push: + tags: + - 'v*' + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: https://gitea.com/actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Generate changelog + id: changelog + env: + CURRENT_TAG: ${{ gitea.ref_name }} + run: | + PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${CURRENT_TAG}$" | head -1) + if [ -z "$PREV_TAG" ]; then + git log --pretty=format:"- %s (%h)" > /tmp/changelog.txt + else + git log "${PREV_TAG}..${CURRENT_TAG}" --pretty=format:"- %s (%h)" > /tmp/changelog.txt + fi + echo "prev_tag=${PREV_TAG}" >> $GITHUB_OUTPUT + + - name: Create Gitea release + env: + GITEA_TOKEN: ${{ gitea.token }} + SERVER_URL: ${{ gitea.server_url }} + REPOSITORY: ${{ gitea.repository }} + CURRENT_TAG: ${{ gitea.ref_name }} + PREV_TAG: ${{ steps.changelog.outputs.prev_tag }} + run: | + CHANGELOG=$(cat /tmp/changelog.txt) + if [ -n "$PREV_TAG" ]; then + COMPARE="**Full diff:** ${SERVER_URL}/${REPOSITORY}/compare/${PREV_TAG}...${CURRENT_TAG}" + else + COMPARE="" + fi + printf '## Changelog\n\n%s\n\n%s' "$CHANGELOG" "$COMPARE" > /tmp/body.md + curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITEA_TOKEN" \ + "${SERVER_URL}/api/v1/repos/${REPOSITORY}/releases" \ + -d "{ + \"tag_name\": \"${CURRENT_TAG}\", + \"name\": \"${CURRENT_TAG}\", + \"body\": $(jq -Rs . /tmp/body.md), + \"draft\": false, + \"prerelease\": false + }" + + - name: Update major version tag + env: + CURRENT_TAG: ${{ gitea.ref_name }} + GITEA_TOKEN: ${{ gitea.token }} + SERVER_URL: ${{ gitea.server_url }} + REPOSITORY: ${{ gitea.repository }} + run: | + MAJOR=$(echo "$CURRENT_TAG" | grep -oP '^v\d+') + SHA=$(git rev-parse HEAD) + # Elimina il tag major esistente e lo ricrea sul commit corrente + curl -s -X DELETE \ + -H "Authorization: token $GITEA_TOKEN" \ + "${SERVER_URL}/api/v1/repos/${REPOSITORY}/tags/${MAJOR}" || true + curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITEA_TOKEN" \ + "${SERVER_URL}/api/v1/repos/${REPOSITORY}/tags" \ + -d "{\"tag_name\": \"${MAJOR}\", \"target\": \"${SHA}\"}" diff --git a/examples/capacitor/ci.yml b/examples/capacitor/ci.yml index d252063..45b48c4 100644 --- a/examples/capacitor/ci.yml +++ b/examples/capacitor/ci.yml @@ -13,11 +13,11 @@ on: jobs: quality-gates: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@v1 secrets: inherit android-debug: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/capacitor-android.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/capacitor-android.yml@v1 secrets: inherit with: build-type: debug diff --git a/examples/capacitor/maintenance.yml b/examples/capacitor/maintenance.yml index 538c327..3e8fb31 100644 --- a/examples/capacitor/maintenance.yml +++ b/examples/capacitor/maintenance.yml @@ -16,10 +16,10 @@ on: jobs: branch-cleanup: if: gitea.event_name == 'pull_request' && gitea.event.pull_request.merged == true - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/branch-cleanup.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/branch-cleanup.yml@v1 secrets: inherit dependency-check: if: gitea.event_name == 'schedule' || gitea.event_name == 'workflow_dispatch' - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/dependency-check.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/dependency-check.yml@v1 secrets: inherit diff --git a/examples/capacitor/release.yml b/examples/capacitor/release.yml index a861d4d..f749c46 100644 --- a/examples/capacitor/release.yml +++ b/examples/capacitor/release.yml @@ -30,19 +30,19 @@ on: jobs: android-apk: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/capacitor-android.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/capacitor-android.yml@v1 secrets: inherit with: build-type: release output-format: apk android-aab: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/capacitor-android.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/capacitor-android.yml@v1 secrets: inherit with: build-type: release output-format: aab gitea-release: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/auto-release.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/auto-release.yml@v1 secrets: inherit diff --git a/examples/libreria-npm/ci.yml b/examples/libreria-npm/ci.yml index 4892e33..5f89be9 100644 --- a/examples/libreria-npm/ci.yml +++ b/examples/libreria-npm/ci.yml @@ -16,5 +16,5 @@ on: jobs: quality-gates: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@v1 secrets: inherit diff --git a/examples/libreria-npm/maintenance.yml b/examples/libreria-npm/maintenance.yml index 7e2d5b7..efc87b5 100644 --- a/examples/libreria-npm/maintenance.yml +++ b/examples/libreria-npm/maintenance.yml @@ -13,10 +13,10 @@ on: jobs: branch-cleanup: if: gitea.event_name == 'pull_request' && gitea.event.pull_request.merged == true - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/branch-cleanup.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/branch-cleanup.yml@v1 secrets: inherit dependency-check: if: gitea.event_name == 'schedule' || gitea.event_name == 'workflow_dispatch' - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/dependency-check.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/dependency-check.yml@v1 secrets: inherit diff --git a/examples/libreria-npm/release.yml b/examples/libreria-npm/release.yml index 4e0e810..c7c5209 100644 --- a/examples/libreria-npm/release.yml +++ b/examples/libreria-npm/release.yml @@ -13,9 +13,9 @@ on: jobs: npm-publish: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/npm-publish.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/npm-publish.yml@v1 secrets: inherit auto-release: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/auto-release.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/auto-release.yml@v1 secrets: inherit diff --git a/examples/microservizio/ci.yml b/examples/microservizio/ci.yml index 6bff7f6..d6494b0 100644 --- a/examples/microservizio/ci.yml +++ b/examples/microservizio/ci.yml @@ -16,7 +16,7 @@ on: jobs: quality-gates: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/quality-gates.yml@v1 secrets: inherit # with: # node-version: '22.17' # opzionale, default già impostato diff --git a/examples/microservizio/maintenance.yml b/examples/microservizio/maintenance.yml index 7e2d5b7..efc87b5 100644 --- a/examples/microservizio/maintenance.yml +++ b/examples/microservizio/maintenance.yml @@ -13,10 +13,10 @@ on: jobs: branch-cleanup: if: gitea.event_name == 'pull_request' && gitea.event.pull_request.merged == true - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/branch-cleanup.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/branch-cleanup.yml@v1 secrets: inherit dependency-check: if: gitea.event_name == 'schedule' || gitea.event_name == 'workflow_dispatch' - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/dependency-check.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/dependency-check.yml@v1 secrets: inherit diff --git a/examples/microservizio/release.yml b/examples/microservizio/release.yml index 801fb36..7c680f4 100644 --- a/examples/microservizio/release.yml +++ b/examples/microservizio/release.yml @@ -13,11 +13,11 @@ on: jobs: docker-release: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/docker-release.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/docker-release.yml@v1 secrets: inherit with: runner: catthehacker-latest # runner con Docker pre-installato auto-release: - uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/auto-release.yml@main + uses: https://gitea.com/Punga78/shared-actions/.gitea/workflows/auto-release.yml@v1 secrets: inherit diff --git a/package.json b/package.json new file mode 100644 index 0000000..6a953a8 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "name": "shared-actions", + "version": "1.0.0", + "description": "Gitea Actions reusable workflows per @pzeta", + "private": true +}