Skip to content

Create tar.gz Folders for Latest Release #56

Create tar.gz Folders for Latest Release

Create tar.gz Folders for Latest Release #56

name: Create tar.gz Folders for Latest Release
on:
workflow_dispatch:
push:
# branches:
# - main # Trigger khi có thay đổi trên branch chính
tags:
- 'v*' # Trigger khi có tag mới
jobs:
build-and-upload:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to get all tags for version comparison
- name: Get the latest tag
id: get_tag
run: |
latest_tag=$(git describe --tags --abbrev=0)
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
echo "📌 Latest tag: ${latest_tag}"
- name: Create tar.gz archives from each directory
run: |
for dir in */; do
dirname="${dir%/}"
if [ "$dirname" == ".github" ]; then
echo "⏩ Skipping .github directory"
continue
fi
echo "📦 Creating '${dirname}.tar.gz'..."
tar --exclude="${dirname}/README.md" -czf "${dirname}.tar.gz" "$dirname"
done
- name: Upload tar.gz files to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ steps.get_tag.outputs.latest_tag }} *.tar.gz --clobber
echo "✅ Successfully uploaded tar.gz files to release '${{ steps.get_tag.outputs.latest_tag }}'"
- name: Clean up artifacts
run: rm -f *.tar.gz