Skip to content

Commit 7ddd22e

Browse files
author
Ryan Carlo Negretti Pereira
authored
Merge pull request RyanCNP#97 from RyanCNP/feature/update-actions
chore: ultima correção do actions
2 parents af32280 + 03cf5e9 commit 7ddd22e

2 files changed

Lines changed: 39 additions & 7 deletions

File tree

.github/workflows/develop-actions.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,43 @@ jobs:
6767
prerelease: true
6868
env:
6969
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
70-
70+
71+
# --- Atualizar e commitar package.json ---
72+
- name: Atualizar versão no package.json
73+
id: update_package
74+
run: |
75+
# Versão atual
76+
CURRENT_VERSION=$(node -p "require('./package.json').version")
77+
echo "📦 Versão atual no package.json: $CURRENT_VERSION"
78+
79+
# Incrementa patch
80+
NEW_VERSION=$(npx semver -i patch "$CURRENT_VERSION")
81+
echo "📦 Nova versão: $NEW_VERSION"
82+
83+
# Atualiza package.json com a nova versão
84+
node -e "
85+
const fs = require('fs');
86+
const pkg = require('./package.json');
87+
pkg.version = '$NEW_VERSION';
88+
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
89+
"
90+
91+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
92+
93+
- name: Commit da nova versão
94+
env:
95+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
96+
run: |
97+
git config user.name "github-actions[bot]"
98+
git config user.email "github-actions[bot]@users.noreply.github.com"
99+
100+
# Ajusta o remote
101+
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git
102+
103+
git add package.json
104+
git commit -m "chore(version): bump to ${{ steps.update_package.outputs.new_version }}" || echo "Sem alterações para commitar"
105+
git push origin develop
106+
71107
# ---- Imagem Docker -----
72108
- name: Login Docker Hub
73109
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a

.github/workflows/main-actions.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ jobs:
118118
echo "✅ A versão no package.json já está atualizada ($CURRENT_VERSION). Nenhuma alteração necessária."
119119
fi
120120
121-
# --- Commit e criar tag ---
122-
- name: Commit e criar tag
121+
# --- Criar tag ---
122+
- name: Criar tag
123123
if: steps.version.outputs.should_deploy == 'true'
124124
env:
125125
NEW_VERSION: ${{ steps.version.outputs.new_version }}
@@ -131,11 +131,7 @@ jobs:
131131
# 🔑 Troca o remote ANTES de qualquer push
132132
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git
133133
134-
git add package.json
135-
git commit -m "chore(release): v$NEW_VERSION" || echo "Sem alterações para commitar"
136-
137134
git tag "v$NEW_VERSION"
138-
git push origin main
139135
git push origin "v$NEW_VERSION"
140136
141137
# --- Criar Release no GitHub ---

0 commit comments

Comments
 (0)