Create tar.gz Folders for Latest Release #17
This file contains hidden or 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: Zip and Upload Folders with GITHUB_TOKEN | |
on: | |
workflow_dispatch: | |
jobs: | |
zip-and-upload: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create zip files for each folder (excluding .github and README.md) | |
run: | | |
mkdir -p zip_outputs | |
for dir in */ ; do | |
folder=$(basename "$dir") | |
if [ "$folder" != ".github" ]; then | |
zip -r "zip_outputs/${folder}.zip" "$dir" -x "${dir}README.md" | |
fi | |
done | |
- name: Get upload URL of release with tag 'latest' | |
id: get_upload_url | |
run: | | |
api_url="https://api.github.com/repos/${{ github.repository }}/releases/tags/latest" | |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$api_url") | |
upload_url=$(echo "$response" | jq -r .upload_url | sed -e "s/{?name,label}//") | |
echo "Upload URL: $upload_url" | |
echo "upload_url=$upload_url" >> "$GITHUB_OUTPUT" | |
- name: Upload zip files using GitHub API | |
run: | | |
for file in zip_outputs/*.zip; do | |
filename=$(basename "$file") | |
echo "Uploading $filename..." | |
curl -s -X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$file" \ | |
"${{ steps.get_upload_url.outputs.upload_url }}?name=$filename" | |
done |