Skip to content

Commit

Permalink
Automatically increment the default version number
Browse files Browse the repository at this point in the history
In theory, we could use GitHub REST API to query the most recent
release version of the mold linker, but the API fails too often,
so we want to write down the latest release version to our config
file.
  • Loading branch information
rui314 committed Nov 19, 2023
1 parent 70f6d05 commit 17aee78
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 "[email protected]"
git commit -am "Update default version to $RELEASE_TAG"
git push
git tag -f v1
git push -f --tags
fi

0 comments on commit 17aee78

Please sign in to comment.