feat: implement semantic versioning for devcontainer releases - #27
Conversation
- Add version.sh script for creating semantic version tags - Create comprehensive versioning documentation - Add Makefile targets for easy version management - Update README with versioning instructions This addresses the issue where all devcontainer releases were tagged as 'latest' only. Manual workflow modification required for complete implementation. Co-authored-by: keito4 <keito4@users.noreply.github.com>
WalkthroughSemantic versioning is introduced for devcontainer image releases through new documentation, a versioning script, and updated Makefile and README instructions. These changes enable automated version tagging (major, minor, patch), version tracking, and integration with GitHub Actions workflows for building and publishing versioned images. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Makefile
participant version.sh
participant Git
participant GitHub Actions
Developer->>Makefile: make version-patch / version-minor / version-major
Makefile->>version.sh: Run with selected bump type
version.sh->>Git: Get latest tag, create new tag
version.sh-->>Developer: Output next steps (push tag)
Developer->>Git: git push --tags
Git->>GitHub Actions: Trigger workflow on tag push
GitHub Actions->>GitHub Actions: Build & publish versioned devcontainer image
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (7)
script/version.sh (1)
6-7: Consider addingset -o pipefailfor robustness.Since the script uses pipelines (e.g.,
git tag -l ... | head -n1), you may miss failures in earlier commands ifset -ealone is used. Addingset -o pipefailensures the script exits on any step failure in a pipeline.README.md (2)
45-52: Ensure versioning prerequisites are clear.It’d be helpful to note that
script/version.shmust be executable (e.g.,chmod +x script/version.sh) before runningmake version-*targets, otherwise Make will error. A single line reminder could save confusion:> Note: Ensure `script/version.sh` is executable (`chmod +x script/version.sh`).
63-69: Link directly to GitHub Actions update instructions.You reference
.devcontainer/VERSIONING.mdfor details, which is great. Consider also adding a one-line pointer in this section reminding users to manually update.github/workflows/docker-image.ymlas outlined in the versioning guide:> Remember to update your workflow at `.github/workflows/docker-image.yml` to trigger on `v*` tags (see link above).Makefile (2)
19-22: Verify script path and permissions in Make targets.The
version-patchtarget calls./script/version.sh, but ifscript/version.shisn’t executable or the working directory differs, it will fail silently. You could guard with:version-patch: @test -x script/version.sh || chmod +x script/version.sh ./script/version.sh --type patch && \ echo "Created patch version tag. Push with: git push origin $$(git describe --tags --abbrev=0)"This ensures the script is runnable before invoking it.
19-22: Use consistent quoting for echoed push commands.Currently you echo:
git push origin \$$(git describe --tags --abbrev=0)Users might find it clearer to wrap the command in backticks or use
$(...)without the extra escape:- echo "Created patch version tag. Push with: git push origin \$$(git describe --tags --abbrev=0)" + echo "Created patch version tag. Push with: git push origin $(git describe --tags --abbrev=0)"This will print the actual tag name instead of the literal
$(git describe…)when Make runs.Also applies to: 23-28
.devcontainer/VERSIONING.md (2)
49-56: Use standard code fences for consistency.The document uses four backticks (````) for fences. For consistency with the rest of the repo (and Markdown standards), switch to three backticks:
-```` +``` # Bump patch version (1.0.0 -> 1.0.1) ./script/version.sh --type patch +```
47-56: Clarify dry-run output behavior.In the script the
--dry-runmode explains the commands, but here the example doesn’t show what users will see. Consider adding an example output snippet to set expectations:```bash $ ./script/version.sh --dry-run DRY RUN: Would create tag v1.0.2 To create this tag, run: git tag v1.0.2 git push origin v1.0.2</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between a18bd574bc887dfc6ba28863e408cbd3a4cf6677 and ed3057d3bf3b41167691b53dda356645040e6210. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `.devcontainer/VERSIONING.md` (1 hunks) * `Makefile` (2 hunks) * `README.md` (1 hunks) * `script/version.sh` (1 hunks) </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| if git tag -l "$NEW_VERSION" | grep -q "$NEW_VERSION"; then | ||
| if [[ "$FORCE" == false ]]; then | ||
| echo -e "${RED}Tag $NEW_VERSION already exists. Use --force to overwrite.${NC}" >&2 | ||
| exit 1 | ||
| else | ||
| echo -e "${YELLOW}Tag $NEW_VERSION already exists but will be overwritten.${NC}" | ||
| fi | ||
| fi |
There was a problem hiding this comment.
Support force-overwrite when creating existing tags.
You check --force and warn about overwrites, but the git tag command at line 128 doesn’t actually use -f. As a result, the tag creation still fails on existing tags even if --force is passed.
A minimal patch:
-if [[ "$DRY_RUN" == true ]]; then
+if [[ "$DRY_RUN" == true ]]; then
echo -e "${YELLOW}DRY RUN: Would create tag $NEW_VERSION${NC}"
…
exit 0
fi
echo -e "${GREEN}Creating tag $NEW_VERSION...${NC}"
-git tag "$NEW_VERSION"
+if [[ "$FORCE" == true ]]; then
+ git tag -f "$NEW_VERSION"
+else
+ git tag "$NEW_VERSION"
+fi
echo -e "${GREEN}Tag created successfully!${NC}"Also applies to: 126-129
🤖 Prompt for AI Agents
In script/version.sh around lines 109 to 116 and 126 to 129, the script checks
for the --force flag and warns about overwriting existing tags, but the actual
git tag creation command does not use the -f option to force overwrite. To fix
this, modify the git tag command to include the -f flag when the FORCE variable
is true, ensuring that existing tags are overwritten as intended when --force is
passed.
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| -t|--type) | ||
| BUMP_TYPE="$2" | ||
| shift 2 | ||
| ;; | ||
| -d|--dry-run) | ||
| DRY_RUN=true | ||
| shift | ||
| ;; | ||
| -f|--force) | ||
| FORCE=true | ||
| shift | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| echo -e "${RED}Unknown option: $1${NC}" >&2 | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Handle missing argument for bump type to avoid silent failures.
The -t|--type case blindly assigns "$2" without verifying that a second argument exists or isn’t another flag. If the user runs ./script/version.sh -t without specifying a type, BUMP_TYPE becomes empty, leading to an “Invalid bump type” error down the line.
Consider adding a check:
case $1 in
-t|--type)
- BUMP_TYPE="$2"
- shift 2
+ if [[ -z "$2" || "$2" == -* ]]; then
+ echo -e "${RED}Error: Missing bump type after $1${NC}" >&2
+ usage
+ exit 1
+ fi
+ BUMP_TYPE="$2"
+ shift 2
;;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| while [[ $# -gt 0 ]]; do | |
| case $1 in | |
| -t|--type) | |
| BUMP_TYPE="$2" | |
| shift 2 | |
| ;; | |
| -d|--dry-run) | |
| DRY_RUN=true | |
| shift | |
| ;; | |
| -f|--force) | |
| FORCE=true | |
| shift | |
| ;; | |
| -h|--help) | |
| usage | |
| exit 0 | |
| ;; | |
| *) | |
| echo -e "${RED}Unknown option: $1${NC}" >&2 | |
| usage | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| while [[ $# -gt 0 ]]; do | |
| case $1 in | |
| -t|--type) | |
| if [[ -z "$2" || "$2" == -* ]]; then | |
| echo -e "${RED}Error: Missing bump type after $1${NC}" >&2 | |
| usage | |
| exit 1 | |
| fi | |
| BUMP_TYPE="$2" | |
| shift 2 | |
| ;; | |
| -d|--dry-run) | |
| DRY_RUN=true | |
| shift | |
| ;; | |
| -f|--force) | |
| FORCE=true | |
| shift | |
| ;; | |
| -h|--help) | |
| usage | |
| exit 0 | |
| ;; | |
| *) | |
| echo -e "${RED}Unknown option: $1${NC}" >&2 | |
| usage | |
| exit 1 | |
| ;; | |
| esac | |
| done |
🤖 Prompt for AI Agents
In script/version.sh around lines 34 to 58, the case handling for the -t|--type
option assigns the next argument to BUMP_TYPE without checking if it exists or
is not another flag, which can cause silent failures. Add a check after
detecting -t|--type to verify that the next argument is present and does not
start with a dash; if the check fails, print an error message about the missing
bump type argument, show usage, and exit with an error code. This prevents empty
or invalid BUMP_TYPE values and improves script robustness.
Summary
Implemented semantic versioning system for devcontainer releases to address issue #25 where all releases were tagged as 'latest'.
Changes
script/version.shfor creating semantic version tags.devcontainer/VERSIONING.mdManual Action Required
The GitHub workflow
.github/workflows/docker-image.ymlneeds manual modification as outlined in the versioning documentation.Usage
Fixes #25
Generated with Claude Code
Summary by CodeRabbit