File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 steps :
1212 - name : Checkout
1313 uses : actions/checkout@v3
14+ with :
15+ token : ${{ secrets.GITHUB_TOKEN }}
1416
1517 - name : Setup Node.js
1618 uses : actions/setup-node@v3
@@ -20,12 +22,25 @@ jobs:
2022
2123 - name : Get release version
2224 id : get_version
23- run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
25+ run : |
26+ VERSION=${GITHUB_REF#refs/tags/}
27+ # Remove 'v' prefix if present
28+ VERSION=${VERSION#v}
29+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
30+ echo "Release version: $VERSION"
2431
2532 - name : Update package.json version
2633 run : |
2734 npm version ${{ steps.get_version.outputs.VERSION }} --no-git-tag-version
2835
36+ - name : Commit version update
37+ run : |
38+ git config --local user.email "action@github.com"
39+ git config --local user.name "GitHub Action"
40+ git add package.json package-lock.json
41+ git commit -m "chore: update version to ${{ steps.get_version.outputs.VERSION }}" || exit 0
42+ git push
43+
2944 - name : Install dependencies
3045 run : npm ci
3146
Original file line number Diff line number Diff line change 2020 "scripts" : {
2121 "build" : " tsc" ,
2222 "dev" : " tsc --watch" ,
23- "format" : " prettier --write nodes credentials"
23+ "format" : " prettier --write nodes credentials" ,
24+ "sync-version" : " git describe --tags --abbrev=0 | sed 's/^v//' | xargs npm version --no-git-tag-version" ,
25+ "release" : " npm run sync-version && npm run build"
2426 },
2527 "files" : [
2628 " dist"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Script para sincronizar a versão do package.json com a última release do GitHub
4+ # Uso: ./sync-version.sh
5+
6+ # Verificar se estamos em um repositório git
7+ if ! git rev-parse --git-dir > /dev/null 2>&1 ; then
8+ echo " Erro: Este não é um repositório git"
9+ exit 1
10+ fi
11+
12+ # Obter a última tag do git
13+ LATEST_TAG=$( git describe --tags --abbrev=0 2> /dev/null)
14+
15+ if [ -z " $LATEST_TAG " ]; then
16+ echo " Nenhuma tag encontrada no repositório"
17+ exit 1
18+ fi
19+
20+ # Remover o prefixo 'v' se presente
21+ VERSION=${LATEST_TAG# v}
22+
23+ echo " Última tag encontrada: $LATEST_TAG "
24+ echo " Versão a ser definida: $VERSION "
25+
26+ # Atualizar a versão no package.json
27+ npm version $VERSION --no-git-tag-version
28+
29+ echo " Versão do package.json atualizada para $VERSION "
30+
31+ # Verificar se há mudanças para commit
32+ if ! git diff --quiet package.json package-lock.json; then
33+ echo " Deseja fazer commit das alterações? (y/n)"
34+ read -r RESPONSE
35+ if [[ " $RESPONSE " =~ ^[Yy]$ ]]; then
36+ git add package.json package-lock.json
37+ git commit -m " chore: sync package version to $VERSION "
38+ echo " Commit realizado com sucesso"
39+ fi
40+ else
41+ echo " Nenhuma alteração necessária - versão já está sincronizada"
42+ fi
You can’t perform that action at this time.
0 commit comments