-
Notifications
You must be signed in to change notification settings - Fork 788
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to update
warn_unsuppported
, warn_eol
labels
The script will automatically assign "warn_unsupported" or "warn_eol" labels based on the information from endoflife.date.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# Adds "warn_unsupported" or "warn_eol" to CRuby definitions based on the | ||
# information from endoflife.date. | ||
|
||
set -e | ||
|
||
date_to_seconds() { | ||
# BSD date | ||
date -jf '%Y-%m-%d' -v 0H -v 0M -v 0S "$1" '+%s' 2>/dev/null || | ||
# GNU date | ||
date --date "$1" '+%s' | ||
} | ||
|
||
now_seconds="$(date '+%s')" | ||
|
||
curl -fsSL https://endoflife.date/api/ruby.json | jq -r '.[] | [.cycle,.eol] | @tsv' | while read -r cycle eol_date; do | ||
eol_seconds="$(date_to_seconds "$eol_date")" | ||
days_to_eol=$(((eol_seconds - now_seconds) / 60 / 60 / 24)) | ||
if [ $days_to_eol -lt 0 ]; then | ||
grep -L warn_eol share/ruby-build/"$cycle"[.-]* | grep -ve '-dev$' | \ | ||
xargs sed -i.bak -E '/openssl/n; s/ warn_unsupported//; s/(.+)"/\1" warn_eol/' | ||
elif [ $days_to_eol -lt 180 ]; then | ||
grep -L warn_unsupported share/ruby-build/"$cycle"[.-]* | grep -ve '-dev$' | \ | ||
xargs sed -i.bak -E '/openssl/n; s/(.+)"/\1" warn_unsupported/' | ||
fi | ||
done | ||
|
||
num_updated="$(rm -fv share/ruby-build/*.bak | wc -l)" | ||
printf "definition files updated: %d\n" "$num_updated" |