Merge pull request #21 from vcatafesta/main #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Criar release e arquivo .tar.gz | |
# Gatilhos para o workflow | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: # Permite a execução manual do workflow | |
inputs: | |
debug_enabled: # Input para habilitar o modo de depuração | |
type: boolean | |
description: "With TMATE" | |
required: false | |
default: false | |
# schedule: # Executa automaticamente toda sexta-feira às 05:00 | |
# - cron: '0 5 * * 5' | |
repository_dispatch: # Permite a execução através de eventos de webhook | |
types: | |
- webhook | |
- "**" | |
# Jobs do workflow | |
jobs: | |
# Job para obter a hora atual | |
get-time: | |
runs-on: ubuntu-latest | |
outputs: | |
time: ${{ steps.time.outputs.time }} # Saída do job | |
steps: | |
- name: Obter a hora atual | |
id: time | |
#run: echo "::set-output name=time::$(date +'%Y.%m.%d-%H%M')" | |
run: echo "time=$(date +'%Y.%m.%d-%H%M')" >> $GITHUB_OUTPUT | |
# Job para definir o nome do repositório | |
set-repo-name: | |
runs-on: ubuntu-latest | |
outputs: | |
REPOSITORY_NAME: ${{ steps.get-repo-name.outputs.repo_name }} | |
steps: | |
- name: Obter nome do repositório | |
id: get-repo-name | |
#run: echo "::set-output name=repo_name::$(basename $GITHUB_REPOSITORY)" | |
run: echo "repo_name=$(basename $GITHUB_REPOSITORY)" >> $GITHUB_OUTPUT | |
# Job para preparar a release | |
prepare-release: | |
runs-on: ubuntu-latest | |
needs: [get-time, set-repo-name] # Depende do job get-time para obter a hora atual e do job set-repo-name para obter o nome do repositório | |
env: | |
REPO_NAME: ${{ needs.set-repo-name.outputs.REPOSITORY_NAME }} | |
steps: | |
- name: Checkout do código | |
uses: actions/checkout@v4 | |
- name: Criar arquivo .tar.gz | |
run: | | |
# Criar arquivo .tar.gz | |
tar -cf ${{ env.REPO_NAME }}.tar.gz . | |
- name: Calculate ISO MD5 Hash | |
shell: bash | |
run: | | |
echo "Calculating MD5 hash for .tar.gz file..." | |
echo "TARBALL is: '${{ env.REPO_NAME }}.tar.gz }}'" | |
if [[ -f "${{ env.REPO_NAME }}.tar.gz" ]]; then | |
sudo md5sum "${{ env.REPO_NAME }}.tar.gz" > "${{ env.REPO_NAME }}.tar.gz.md5" | |
echo "MD5 hash calculated and saved:" | |
cat "${{ env.REPO_NAME }}.tar.gz.md5" | |
else | |
echo "Error: ISO file '${{ env.REPO_NAME }}.tar.gz' not found" | |
exit 1 | |
fi | |
- name: Salvar arquivo .tar.gz como artefato | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.REPO_NAME }}.tar.gz | |
path: | | |
${{ env.REPO_NAME }}.tar.gz | |
- name: Salvar arquivo .tar.gz.md5 como artefato | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.REPO_NAME }}.tar.gz.md5 | |
path: | | |
${{ env.REPO_NAME }}.tar.gz.md5 | |
- name: Criar release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} | |
with: | |
tag_name: ${{ needs.get-time.outputs.time }} | |
release_name: Release ${{ needs.get-time.outputs.time }} | |
body: | | |
- **Data e Hora :** ${{ needs.get-time.outputs.time }} | |
- **Nome do Repositório:** ${{ env.REPO_NAME }} | |
- **Arquivo tar :** ${{ env.REPO_NAME }}.tar.gz | |
- **Arquivo md5 :** ${{ env.REPO_NAME }}.tar.gz.md5 | |
draft: false | |
prerelease: false | |
- name: Fazer upload do arquivo .tar.gz no release | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ env.REPO_NAME }}.tar.gz | |
asset_name: ${{ env.REPO_NAME }}.tar.gz | |
asset_content_type: application/gzip | |
- name: Fazer upload do arquivo tar.gz.md5 no release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ env.REPO_NAME }}.tar.gz.md5 | |
asset_name: ${{ env.REPO_NAME }}.tar.gz.md5 | |
asset_content_type: text/plain |