chore: move update-version to ci

Eliminate the GitHub workflow for automatic README updates and adjust the README files to reflect the new version tag. This change streamlines the process by removing redundant steps and ensures explicit control over version increments.

chore: add dependabot.yml (#302)

chore(deps): bump oven-sh/setup-bun from 1 to 2 (#305)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Update checkout action to fetch all tags

Improve version update script to handle errors

- Change version increment logic to handle missing tags.
- Add error handling for version mismatches in README.md files.
- Display directories with changed files for better visibility.

Improve version bumping process in update script

By checking for diffs after processing each README.md, we can
ensure that only modified files trigger version bump messages.
This change also refines the status check to target README.md files
specifically, aiding in precise error handling.

Clarify update script comment for version bumping

Improve version check and output in scripts

- Enhance visibility of version mismatches by focusing git diff on README.md files.
- Use command substitution to improve clarity in conditional checks.

Apply suggestions from code review

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

simplify

specify shell

Update ci.yaml

Update ci.yaml

Update update-version.sh

Update ci.yaml

Enhance version bump logic output in script

- Improve the clarity of version bump output by specifying current
  and incremented versions.
- Add additional message for unchanged README.md files.
pull/301/head
Muhammad Atif Ali 10 months ago
parent c2ec4cbfc6
commit 70e6092360

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup
@ -27,7 +27,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
fetch-depth: 0 # Needed to get tags
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup
@ -37,13 +39,17 @@ jobs:
- name: typos-action
uses: crate-ci/typos@v1.17.2
- name: Lint
run: bun lint
- name: Check version
shell: bash
run: |
bun lint
# check for version changes
./update-version.sh
if [[ `git status --porcelain` ]]; then
echo "Version mismatch. Please run ./update-version.sh"
# Check if any changes were made in README.md files
if [[ -n "$(git status --porcelain -- '**/README.md')" ]]; then
echo "Version mismatch detected. Please run ./update-version.sh and commit the updated README.md files."
git diff -- '**/README.md'
exit 1
else
echo "No changes detected."
echo "No version mismatch detected. All versions are up to date."
fi

@ -1,42 +0,0 @@
name: Update README on Tag
on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
update-readme:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get the latest tag
id: get-latest-tag
run: echo "TAG=$(git describe --tags --abbrev=0 | sed 's/^v//')" >> $GITHUB_OUTPUT
- name: Run update script
run: ./update-version.sh
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
commit-message: 'chore: bump version to ${{ env.TAG }} in README.md files'
title: 'chore: bump version to ${{ env.TAG }} in README.md files'
body: 'This is an auto-generated PR to update README.md files of all modules with the new tag ${{ env.TAG }}'
branch: 'update-readme-branch'
base: 'main'
env:
TAG: ${{ steps.get-latest-tag.outputs.TAG }}
- name: Auto-approve
uses: hmarr/auto-approve-action@v4
if: github.ref == 'refs/heads/update-readme-branch'

@ -16,7 +16,7 @@ Uses the [Coder Remote VS Code Extension](https://github.com/coder/cursor-coder)
```tf
module "cursor" {
source = "registry.coder.com/modules/cursor/coder"
version = "1.0.18"
version = "1.0.19"
agent_id = coder_agent.example.id
}
```
@ -28,7 +28,7 @@ module "cursor" {
```tf
module "cursor" {
source = "registry.coder.com/modules/cursor/coder"
version = "1.0.18"
version = "1.0.19"
agent_id = coder_agent.example.id
folder = "/home/coder/project"
}

@ -16,7 +16,7 @@ A module that adds Jupyter Notebook in your Coder template.
```tf
module "jupyter-notebook" {
source = "registry.coder.com/modules/jupyter-notebook/coder"
version = "1.0.8"
version = "1.0.19"
agent_id = coder_agent.example.id
}
```

@ -16,7 +16,7 @@ A module that adds JupyterLab in your Coder template.
```tf
module "jupyterlab" {
source = "registry.coder.com/modules/jupyterlab/coder"
version = "1.0.8"
version = "1.0.19"
agent_id = coder_agent.example.id
}
```

@ -1,20 +1,24 @@
#!/usr/bin/env bash
# This script updates the version number in the README.md files of all modules
# to the latest tag in the repository. It is intended to be run from the root
# This script increments the version number in the README.md files of all modules
# by 1 patch version. It is intended to be run from the root
# of the repository or by using the `bun update-version` command.
set -euo pipefail
current_tag=$(git describe --tags --abbrev=0)
previous_tag=$(git describe --tags --abbrev=0 $current_tag^)
mapfile -t changed_dirs < <(git diff --name-only "$previous_tag"..."$current_tag" -- ':!**/README.md' ':!**/*.test.ts' | xargs dirname | grep -v '^\.' | sort -u)
LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') || exit $?
# Increment the patch version
LATEST_TAG=$(echo "$current_tag" | sed 's/^v//' | awk -F. '{print $1"."$2"."$3+1}') || exit $?
# List directories with changes that are not README.md or test files
mapfile -t changed_dirs < <(git diff --name-only "$current_tag" -- ':!**/README.md' ':!**/*.test.ts' | xargs dirname | grep -v '^\.' | sort -u)
echo "Directories with changes: ${changed_dirs[*]}"
# Iterate over directories and update version in README.md
for dir in "${changed_dirs[@]}"; do
if [[ -f "$dir/README.md" ]]; then
echo "Bumping version in $dir/README.md"
file="$dir/README.md"
tmpfile=$(mktemp /tmp/tempfile.XXXXXX)
awk -v tag="$LATEST_TAG" '{
@ -25,5 +29,12 @@ for dir in "${changed_dirs[@]}"; do
print
}
}' "$file" > "$tmpfile" && mv "$tmpfile" "$file"
# Check if the README.md file has changed
if ! git diff --quiet -- "$dir/README.md"; then
echo "Bumping version in $dir/README.md from $current_tag to $LATEST_TAG (incremented)"
else
echo "Version in $dir/README.md is already up to date"
fi
fi
done

Loading…
Cancel
Save