Skip to content

Commit 39b4cbd

Browse files
committed
bump version to 0.2.3 and add GitHub Actions workflow for automatic version tagging
1 parent 3204d73 commit 39b4cbd

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

.github/workflows/tag-version.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Create and Push Version Tag
2+
3+
# Gatilho: Executa este workflow em cada push para a branch 'main'
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
# Permissões: Concede ao workflow permissão para ler o conteúdo do repositório
10+
# e escrever (para poder criar e empurrar a tag).
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
tag-version:
16+
name: Tag Version from pyproject.toml
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
# Passo 1: Clona o repositório para o ambiente de execução do workflow
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
# Precisamos buscar todo o histórico para verificar as tags existentes
25+
fetch-depth: 0
26+
27+
# Passo 2: Configura o ambiente Python para ler o arquivo .toml
28+
# Mesmo que seja um comando simples, usar um setup garante a disponibilidade do Python.
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.10' # Você pode ajustar para a sua versão de preferência
33+
34+
# Passo 3: Instala a biblioteca tomli para ler o arquivo TOML de forma segura
35+
# tomli é a biblioteca padrão para ler .toml no Python 3.11+ e recomendada para versões anteriores.
36+
- name: Install tomli
37+
run: pip install tomli
38+
39+
# Passo 4: O passo principal - lê a versão, cria e empurra a tag
40+
- name: Get version, create and push tag
41+
id: get_version
42+
run: |
43+
echo "Lendo a versão do arquivo pyproject.toml..."
44+
45+
# Extrai a versão do pyproject.toml usando Python e tomli.
46+
# Adapte o caminho ['project']['version'] se sua versão estiver em outro lugar (ex: ['tool']['poetry']['version'])
47+
PROJECT_VERSION=$(python -c "import tomli; f = open('pyproject.toml', 'rb'); data = tomli.load(f); print(data['project']['version'])")
48+
49+
if [ -z "$PROJECT_VERSION" ]; then
50+
echo "ERRO: Não foi possível encontrar a versão no pyproject.toml."
51+
exit 1
52+
fi
53+
54+
# Constrói o nome da tag no formato vX.Y.Z
55+
TAG="v$PROJECT_VERSION"
56+
echo "Versão encontrada: $PROJECT_VERSION"
57+
echo "Tag a ser criada: $TAG"
58+
59+
# Verifica se a tag já existe no repositório
60+
# git rev-parse usa a tag para encontrar o commit. Se falhar, a tag não existe.
61+
if git rev-parse "$TAG" >/dev/null 2>&1; then
62+
echo "A tag $TAG já existe. Nenhuma ação será tomada."
63+
exit 0 # Termina o job com sucesso
64+
fi
65+
66+
echo "A tag $TAG não existe. Criando e empurrando a tag..."
67+
68+
# Configura o Git com o nome e e-mail do bot do GitHub Actions
69+
git config user.name "github-actions[bot]"
70+
git config user.email "github-actions[bot]@users.noreply.github.com"
71+
72+
# Cria a tag apontando para o commit atual
73+
git tag -a "$TAG" -m "Release version $TAG"
74+
75+
# Empurra a nova tag para o repositório remoto (origin)
76+
git push origin "$TAG"
77+
78+
echo "Tag $TAG criada e empurrada com sucesso!"

.idea/office365-service.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "office365-service"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "Add your description here"
55
readme = "README.md"
66
authors = [

0 commit comments

Comments
 (0)