Skip to content

v1.1.3

v1.1.3 #21

name: Zip Folders On Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
zip-and-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create zip archives for each top-level folder
shell: bash
run: |
set -euo pipefail
mkdir -p dist
TAG_NAME="${{ github.event.release.tag_name }}"
VERSION="${TAG_NAME#v}"
export VERSION
echo "Release tag: ${TAG_NAME}"
echo "Normalized version: ${VERSION}"
python3 - <<'PY'
import json
import os
version = os.environ["VERSION"]
updated = 0
for root, _, files in os.walk("."):
if "script.json" in files:
path = os.path.join(root, "script.json")
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
data["version"] = version
with open(path, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
f.write("\n")
updated += 1
print(f"Updated {path}")
print(f"Updated {updated} script.json file(s).")
PY
for dir in */; do
folder="${dir%/}"
# Skip metadata, build output, and src folders if present.
if [[ "$folder" == ".github" || "$folder" == "dist" || "$folder" == "src" ]]; then
continue
fi
echo "Zipping $folder -> dist/${folder}.zip"
zip -r "dist/${folder}.zip" "$folder"
done
echo "Generated archives:"
ls -lh dist
- name: Upload archives to the release
uses: softprops/action-gh-release@v2
with:
files: dist/*.zip
overwrite_files: true
env:
GITHUB_TOKEN: ${{ secrets.REALEASE_TOKEN }}