Skip to content

Rename Release Assets #6

Rename Release Assets

Rename Release Assets #6

name: Rename Release Assets
on:
release:
types:
- published
- edited
jobs:
rename:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get list of release assets
id: assets
run: |
assets=$(curl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--url https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets \
| jq -r '.[] | .browser_download_url')
echo 'urls<<EOF' >> $GITHUB_OUTPUT
echo "$assets" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Download, rename and re-upload release assets
run: |
for url in "${{ steps.assets.outputs.urls }}"; do
file="$(basename "$url")"
echo "Processing $file..."
case $file in
Rivet_*_universal.dmg|Rivet_*_amd64.AppImage|Rivet_*_amd64.deb)
echo "Downloading $url..."
wget --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" $url
new_file=$(echo $file | sed 's/_.*//').${file##*.}
mv $file $new_file
echo "Uploading $new_file..."
gh release upload ${{ github.event.release.tag_name }} $new_file --clobber
;;
esac
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}