|
| 1 | +# scripts/release.ps1 |
| 2 | +$ErrorActionPreference = 'Stop' # Exit immediately if a command exits with a non-zero status. |
| 3 | + |
| 4 | +Write-Host "Optimizing new version submission flow (PowerShell compatible)..." |
| 5 | + |
| 6 | +# 1. Ensure clean git working directory |
| 7 | +Write-Host "Checking for uncommitted changes..." |
| 8 | +$gitStatus = git status --porcelain |
| 9 | +if ($gitStatus) { |
| 10 | + Write-Host "Error: Uncommitted changes detected. Please commit or stash them before running the release script." |
| 11 | + exit 1 |
| 12 | +} |
| 13 | + |
| 14 | +# 2. Bump version, create commit and tag |
| 15 | +Write-Host "Bumping version and creating tag..." |
| 16 | +# `bun pm version patch` automatically updates package.json and bun.lockb, then creates a commit and a tag like vX.Y.Z |
| 17 | +bun run version:patch |
| 18 | +$oldVersionOutput = bun pm pkg get version |
| 19 | +$newVersionOutput = $oldVersionOutput |
| 20 | +$NEW_VERSION = ($newVersionOutput | Select-Object -Last 1).Trim() # Assumes the last line is the version, e.g., "v1.0.1" |
| 21 | +Write-Host "Version bumped to $NEW_VERSION" |
| 22 | + |
| 23 | +# 2. Generate CHANGELOG.md |
| 24 | +Write-Host "Generating CHANGELOG.md..." |
| 25 | +bun run changelog |
| 26 | + |
| 27 | +# 3. Run format and lint:fix to ensure all files (including package.json and CHANGELOG.md) adhere to standards |
| 28 | +# This step might modify package.json and CHANGELOG.md again if they were not perfectly formatted |
| 29 | +Write-Host "Running Build to ensure consistency..." |
| 30 | +bun run expo:prebuild # Reformats files, including package.json and CHANGELOG.md if needed |
| 31 | +#bun run lint:fix # Fixes linting issues, could touch files again |
| 32 | + |
| 33 | +# 4. Stage all changes that occurred since the last commit (which was the version bump) |
| 34 | +# This includes CHANGELOG.md and any reformatting applied to package.json (or other files touched by format/lint) |
| 35 | +Write-Host "Staging all remaining changes (CHANGELOG.md and formatting updates)..." |
| 36 | +git add . # Use 'git add .' to stage all modifications |
| 37 | + |
| 38 | +# 5. Amend the previous commit (the version bump commit) to include these new staged changes |
| 39 | +# git commit --amend --no-edit keeps the existing commit message (e.g., "vX.Y.Z") |
| 40 | +Write-Host "Amending previous commit to include CHANGELOG.md and formatting changes..." |
| 41 | +git commit --amend --no-edit |
| 42 | + |
| 43 | +# 6. Force update the tag to point to the amended commit (important!) |
| 44 | +# `git commit --amend` creates a new commit SHA. We need to update the tag to point to this new SHA. |
| 45 | +Write-Host "Updating Git tag $NEW_VERSION to new commit SHA..." |
| 46 | +git tag -f $NEW_VERSION HEAD |
| 47 | + |
| 48 | +# 7. Run the project build (dist/ is ignored, so it's not committed) |
| 49 | +Write-Host "Running project build..." |
| 50 | +bun run expo:prebuild |
| 51 | + |
| 52 | +Write-Host "Release process complete for version $NEW_VERSION." |
| 53 | +Write-Host "Now Running: git push && git push --tags" |
| 54 | +git push |
| 55 | +git push --tags |
0 commit comments