-
Notifications
You must be signed in to change notification settings - Fork 10
38 lines (33 loc) · 1.21 KB
/
update-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Update Default Mold Version
on:
schedule:
- cron: '0 0 * * *'
jobs:
check-update-mold-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update action.yml if needed
run: |
set -x
curl -s https://api.github.com/repos/rui314/mold/releases/latest > info
RELEASE_TAG=$(jq -r .tag_name info | sed 's/^v//')
RELEASE_DATE=(jq -r .published_at info)
CURRENT_TAG=$(grep default: action.yml | head -1 | cut -d "'" -f 2)
echo "$RELEASE_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'
if [ $CURRENT_TAG = $RELEASE_TAG ]; then
echo "action.yml is already up to date"
elif [ $(date +%s) -lt $(date -d "$RELEASE_DATE + 7 days" +%s) ]; then
echo "still in grace period"
else
sed -i "s/default: '.*'/default: '$RELEASE_TAG'/" action.yml
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git commit -am "Update default version to $RELEASE_TAG"
git push
git tag -f v1
git push -f --tags
fi