.mise/tasks/mise-upgrade
.mise/tasks/mise-upgradeBrowse 1970 files
1,173 tokens
4,320 bytes
Token encoding: o200k_base
Snapshot 21a254f
← Back to SKILL.md
1#!/usr/bin/env bash2# Description: one-click command to check for a new mise version and create a PR to update core/mise/version.txt.3 4set -euo pipefail5 6repo_root="$(git rev-parse --show-toplevel)"7cd "$repo_root"8 9# Check that we're on the main branch10current_branch="$(git branch --show-current)"11if [[ "$current_branch" != "main" ]]; then12 echo "Error: must be on 'main' branch, currently on '$current_branch'" >&213 exit 114fi15 16# Pull latest changes from the canonical railpack remote17canonical_repo="railwayapp/railpack"18canonical_url="https://github.com/$canonical_repo"19remote_name=$(git remote -v | grep "$canonical_repo" | head -n1 | awk '{print $1}')20 21if [[ -n "$remote_name" ]]; then22 echo "Updating from remote: $remote_name ($canonical_url)"23 git fetch "$remote_name" main24 git pull "$remote_name" main25 base_branch="$remote_name/main"26else27 echo "Updating from URL: $canonical_url"28 git fetch "$canonical_url" main29 git pull "$canonical_url" main30 base_branch="FETCH_HEAD"31fi32 33# Require clean working tree for tracked files34if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then35 echo "Error: tracked files are dirty. Commit or stash first." >&236 exit 137fi38 39# Tooling checks40if ! command -v gh >/dev/null 2>&1; then41 echo "Error: gh CLI is required (brew install gh)." >&242 exit 143fi44 45# Get latest mise tag via GitHub API46latest_tag="$(gh release view --repo jdx/mise --json tagName --jq .tagName)"47if [[ -z "$latest_tag" ]]; then48 echo "Error: could not determine latest mise release tag" >&249 exit 150fi51latest="${latest_tag#v}"52 53file="$repo_root/core/mise/version.txt"54if [[ ! -f "$file" ]]; then55 echo "Error: $file not found" >&256 exit 157fi58 59branch="chore/update-mise-$latest"60if git show-ref --verify --quiet "refs/heads/$branch"; then61 echo "Local branch $branch already exists." >&262 exit 163fi64 65git switch -c "$branch" "$base_branch"66 67# Write the new version to version.txt68printf "%s" "$latest" > "$file"69 70new="$(cat "$file")"71if [[ "$new" != "$latest" ]]; then72 echo "Error: failed to update version in $file" >&273 exit 174fi75 76# although there are other updates below that are NOT tied to mise, linking all maint work to a mise upgrade77# eliminates daily PRs which would be annoying and groups these changes with important updates (mise versions)78# which impact our users.79if git diff --quiet -- "$file"; then80 echo "mise version already set to $latest. Nothing to do."81 exit 082fi83 84# `fix` scope because mise versions do impact the end-user functionality85git add -- "$file"86git commit -m "fix: update mise to $latest"87 88# Update snapshots before running any assertion tests — a new mise version89# will always produce different snapshots, so assertions must come after.90mise run test-update-snapshots91if ! git diff --cached --quiet; then92 git commit -F "$(git rev-parse --git-dir)/COMMIT_EDITMSG"93fi94 95echo "Upgrading go and mise packages..."96mise run upgrade97if [[ -n "$(git status --porcelain go.mod go.sum)" ]]; then98 git add go.mod go.sum docs/package.json mise.lock docs/bun.lock99 git commit -m "chore: update go, mise, and bun packages"100fi101 102echo "Running autofix fixes..."103mise run fix104if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then105 git add .106 git commit -m "refactor: modernize code with go fix"107fi108 109echo "Running checks and linting..."110mise run check111if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then112 git add .113 git commit -m "style: fix formatting"114fi115 116echo "Updating test files..."117mise --cd examples/python-uv-latest-locked upgrade --local118if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then119 git add examples/python-uv-latest-locked120 git commit -m "test: update mise lock with latest version"121fi122 123echo "Updating docs changelog from GitHub releases..."124changelog_file="docs/src/content/docs/changelog.md"125if mise run docs-generate-changelog; then126 if [[ -n "$(git status --porcelain -- "$changelog_file")" ]]; then127 git add -- "$changelog_file"128 git commit -m "docs: updated changelog"129 fi130else131 echo "Error: failed to generate docs changelog (continuing upgrade)" >&2132fi133 134# Push the branch (needed in CI and good practice locally)135git push -u origin "$branch"136 137gh pr create \138 --repo "$canonical_repo" \139 --title "chore: mise update $latest" \140 --body "Update mise to $latest"141