Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: tag submodules #1338

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/tag_modules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Create Module Tags

on:
push:
tags:
- '*'

jobs:
validate-and-create-tags:
runs-on: ${{ vars.RUNNER_RUNS_ON }}
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0

- name: Validate tag format
id: validate-tag
run: |
chmod +x ./scripts/create_module_tags.sh
./scripts/create_module_tags.sh "${{ github.ref_name }}"

- name: Import GPG key
id: import-gpg-key
if: steps.validate-tag.outcome == 'success'
run: |
echo "${{ secrets.MAGALUBOT_GPG_PRIVATE_KEY }}" | gpg --batch --yes --passphrase "${{ secrets.MAGALUBOT_GPG_PASSPHRASE }}" --import

- name: Create and push module tags
if: steps.import-gpg-key.outcome == 'success'
run: |
# Configurar usuário do Git
git config --global user.name "${{vars.MAGALUBOT_USER_NAME}}"
git config --global user.email "${{vars.MAGALUBOT_EMAIL}}"
git config --global commit.gpgsign true
git config --global tag.gpgsign true
git config --global user.signingkey $(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)

TAG_NAME="${{ github.ref_name }}"

# Criar as novas tags
git tag "mgc/lib/$TAG_NAME" -m "chore: bump version $TAG_NAME"
git tag "mgc/sdk/$TAG_NAME" -m "chore: bump version $TAG_NAME"
git tag "mgc/core/$TAG_NAME" -m "chore: bump version $TAG_NAME"

# Fazer push das novas tags
git push origin "mgc/lib/$TAG_NAME"
git push origin "mgc/sdk/$TAG_NAME"
git push origin "mgc/core/$TAG_NAME"
19 changes: 19 additions & 0 deletions scripts/create_module_tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Captura o input da versão
version="$1"

# Verifica se o input foi fornecido
if [ -z "$version" ]; then
echo "Erro: Nenhuma versão fornecida."
exit 1
fi

# Expressão regular para validar o padrão sem sufixos
if [[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Versão válida: $version"
exit 0 # Sucesso
else
echo "Erro: Versão inválida para publicação de sub modulos: $version"
exit 1 # Erro
fi
Loading