tag-stable-weekly #14
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
name: tag-stable-weekly | |
on: | |
schedule: | |
- cron: "0 4 * * MON" | |
jobs: | |
weekly-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Fetch all tags | |
run: | | |
git config --global --add safe.directory /__w/kraftkit/kraftkit | |
git fetch --force --tags | |
- name: Tag new patch version | |
run: | | |
set -xe | |
LATEST_TAG=$(curl -s "https://get.kraftkit.sh/latest.txt") | |
# Check if LATEST_TAG has semver format | |
if [[ ! $LATEST_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
echo "Latest tag has invalid format, is 'https://get.kraftkit.sh/latest.txt' down?: $LATEST_TAG" | |
exit 1 | |
fi | |
# If diff between staging and latest is 0, exit | |
git log --pretty=format:"%h: %s" staging..."v${LATEST_TAG}" > latest_changes | |
if [[ $(wc -l < latest_changes) -eq 0 ]]; then | |
echo "No changes between staging and latest tag, exiting" | |
exit 0 | |
fi | |
# Split LATEST_TAG on '.' and increment the last number | |
IFS='.' read -r -a array <<< "$LATEST_TAG" | |
array[2]=$((array[2]+1)) | |
NEW_TAG="v${array[0]}.${array[1]}.${array[2]}" | |
# Rebase stable on staging | |
git checkout stable | |
git rebase staging | |
# Create PR with current branch | |
NEW_BRANCH="unikraft-bot/weekly-tag-${NEW_TAG}" | |
git checkout -b "${NEW_BRANCH}" | |
git push origin "${NEW_BRANCH}" | |
gh pr create --title "chore(bump): KraftKit ${NEW_TAG} bump" --body "Weekly tag: ${NEW_TAG}" --base stable --head "${NEW_BRANCH}" --repo unikraft/kraftkit | |
# Merge PR and delete branch | |
gh pr merge --admin --author-email "monkey@unikraft.io" --delete-branch --rebase --repo unikraft/kraftkit | |
# Tag and push new tag | |
git checkout stable | |
git tag -a "$NEW_TAG" -m "KraftKit $NEW_TAG" | |
git push origin "$NEW_TAG" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} |