|
1 | | -name: Zip Folders and Upload to Release |
| 1 | +name: Zip Folders and Upload to GitHub Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | 5 |
|
6 | 6 | jobs: |
7 | | - zip-and-release: |
| 7 | + zip-and-upload: |
8 | 8 | runs-on: ubuntu-latest |
9 | 9 |
|
10 | 10 | steps: |
11 | | - - name: Checkout code |
| 11 | + - name: Checkout repository |
12 | 12 | uses: actions/checkout@v4 |
13 | 13 |
|
14 | | - - name: Zip each folder (excluding .github and README.md) |
| 14 | + - name: Find folders and zip them |
| 15 | + id: zip |
15 | 16 | run: | |
16 | 17 | mkdir -p zip_outputs |
17 | 18 | for dir in */ ; do |
18 | 19 | if [[ "$dir" != ".github/" && -d "$dir" ]]; then |
19 | 20 | name="${dir%/}" |
20 | | - echo "Zipping $name" |
| 21 | + echo "Zipping $name..." |
21 | 22 | zip -r "zip_outputs/${name}.zip" "$name" -x "$name/README.md" |
22 | 23 | fi |
23 | 24 | done |
24 | 25 |
|
25 | 26 | - name: Get latest release tag |
26 | 27 | id: get_release |
27 | 28 | run: | |
28 | | - tag=$(gh release list --limit 1 --json tagName -q '.[0].tagName' || echo "") |
29 | | - if [[ -z "$tag" ]]; then |
30 | | - tag="auto-zip-$(date +%Y%m%d-%H%M%S)" |
31 | | - echo "No existing release. Creating new release with tag $tag" |
32 | | - gh release create "$tag" --title "Auto Zip Release $tag" --notes "Auto-generated zip files" |
33 | | - else |
34 | | - echo "Found existing release tag: $tag" |
35 | | - fi |
| 29 | + tag=$(gh release list --limit 1 --json tagName -q '.[0].tagName') |
| 30 | + echo "Latest tag is: $tag" |
36 | 31 | echo "tag=$tag" >> $GITHUB_OUTPUT |
37 | 32 | env: |
38 | 33 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
39 | 34 |
|
40 | | - - name: Ensure 'latest' release exists |
41 | | - run: | |
42 | | - if ! gh release view latest &>/dev/null; then |
43 | | - echo "Creating 'latest' release" |
44 | | - gh release create latest --title "Latest Auto Zip" --notes "Auto-generated zip files (latest)" |
45 | | - fi |
46 | | - env: |
47 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
48 | | - |
49 | | - - name: Upload zip files to releases |
| 35 | + - name: Upload zip files to latest release |
50 | 36 | run: | |
51 | 37 | for file in zip_outputs/*.zip; do |
52 | | - echo "Uploading $file to tag: ${{ steps.get_release.outputs.tag }} and 'latest'" |
53 | 38 | gh release upload "${{ steps.get_release.outputs.tag }}" "$file" --clobber |
54 | | - gh release upload "latest" "$file" --clobber |
| 39 | + gh release upload "latest" "$file" --clobber || true |
55 | 40 | done |
56 | 41 | env: |
57 | 42 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments