diff --git a/.github/workflows/tag_modules.yaml b/.github/workflows/tag_modules.yaml new file mode 100644 index 000000000..f37a9ec98 --- /dev/null +++ b/.github/workflows/tag_modules.yaml @@ -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" \ No newline at end of file diff --git a/scripts/create_module_tags.sh b/scripts/create_module_tags.sh new file mode 100755 index 000000000..1f631273d --- /dev/null +++ b/scripts/create_module_tags.sh @@ -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 \ No newline at end of file