Skip to content

Commit

Permalink
try to fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
devl00p committed Aug 5, 2024
1 parent 8404210 commit 41ac06d
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions .github/workflows/make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,38 @@ jobs:
draft: false
prerelease: false

- name: Upload Release Assets
- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: Authenticate GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Find all files to upload
files=$(find releases -name '*.json.xz')
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh auth status
# Loop over files and upload each one
for file in $files; do
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Release ID: ${{ steps.create_release.outputs.id }}"
for file in releases/*.json.xz; do
echo "Uploading $file"
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/zip" \
--data-binary @"$file" \
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $file)"
gh release upload ${{ steps.create_release.outputs.id }} "$file" --clobber || echo "Failed to upload $file"
done
- name: Remove old releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Install GitHub CLI
sudo apt-get update
sudo apt-get install -y gh
# Authenticate GitHub CLI
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
# Get the current date in seconds since epoch
current_date=$(date +%s)
# List all releases
gh release list --limit 100 | while read -r release; do
release_date=$(echo $release | awk '{print $NF}')
release_date_seconds=$(date -d $release_date +%s)
release_id=$(echo $release | awk '{print $1}')
# Calculate the age of the release in days
release_age_days=$(( (current_date - release_date_seconds) / 86400 ))
# Delete releases older than 30 days
if [ $release_age_days -gt 30 ]; then
echo "Deleting release $release_id (age: $release_age_days days)"
gh release delete $release_id --yes
Expand Down

0 comments on commit 41ac06d

Please sign in to comment.