Skip to content

Commit e35a62b

Browse files
swap release action
1 parent 55106c0 commit e35a62b

File tree

1 file changed

+19
-36
lines changed

1 file changed

+19
-36
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -89,54 +89,37 @@ jobs:
8989
with:
9090
name: ${{ steps.set_filename.outputs.ASSET_NAME }}
9191
path: dist/${{ steps.set_filename.outputs.ASSET_NAME }}
92-
9392
release:
9493
name: Create GitHub Release
9594
runs-on: ubuntu-latest
96-
needs: build # This job depends on all 'build' jobs completing successfully
95+
needs: build
9796
if: success() && github.ref_type == 'tag'
9897

9998
permissions:
10099
contents: write # For creating the release and uploading assets
101-
actions: read # Needed by actions/github-script to list workflow runs/artifacts
102-
checks: read # Good practice, often used with actions/github-script
103-
pull-requests: read # Not strictly needed for this, but common
104-
statuses: read # Not strictly needed for this, but common
100+
actions: read # Not strictly needed for softprops/action-gh-release, but harmless
101+
# Removed: checks, pull-requests, statuses - often not needed for release action specifically
105102

106103
steps:
107-
- name: Create Release
108-
id: create_release
109-
uses: actions/create-release@v1.1.4
110-
env:
111-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is automatically provided by GitHub
112-
with:
113-
tag_name: ${{ github.ref }}
114-
release_name: Release ${{ github.ref }}
115-
draft: false
116-
prerelease: false
117-
118104
- name: Download all build artifacts
105+
# Keep this step as softprops/action-gh-release can directly consume files from a directory
119106
uses: actions/download-artifact@v4
120107
with:
121108
path: release_assets # Download all artifacts into this directory
122109

123-
- name: Install GitHub CLI
124-
run: |
125-
sudo apt-get update
126-
sudo apt-get install -y gh
127-
128-
- name: Upload artifacts to release
129-
run: |
130-
# The download-artifact action creates a directory for each artifact name.
131-
# So your structure will be release_assets/ASSET_NAME/actual_file
132-
# You need to iterate through these
133-
find release_assets -type f -print0 | while IFS= read -r -d $'\0' file; do
134-
if [ -f "$file" ]; then
135-
echo "Uploading $file to release"
136-
gh release upload "${{ github.ref_name }}" "$file" --repo "${{ github.repository }}" --clobber
137-
else
138-
echo "Skipping non-file: $file"
139-
fi
140-
done
110+
- name: Create GitHub Release
111+
uses: softprops/action-gh-release@v2 # Using the recommended action version 2
141112
env:
142-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
tag_name: ${{ github.ref }}
116+
name: Release ${{ github.ref }} # 'name' instead of 'release_name'
117+
draft: false
118+
prerelease: false
119+
# Here's the magic: Directly upload all downloaded artifacts!
120+
# This finds all files within any subdirectory under release_assets/
121+
files: release_assets/**/*
122+
# If you wanted to be more specific, e.g., only zip and tar.gz:
123+
# files: |
124+
# release_assets/**/*.zip
125+
# release_assets/**/*.tar.gz

0 commit comments

Comments
 (0)