Skip to content

Commit 70e6092

Browse files
committed
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.
1 parent c2ec4cb commit 70e6092

File tree

7 files changed

+39
-58
lines changed

7 files changed

+39
-58
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/ci.yaml

+12-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
20-
- uses: oven-sh/setup-bun@v1
20+
- uses: oven-sh/setup-bun@v2
2121
with:
2222
bun-version: latest
2323
- name: Setup
@@ -27,7 +27,9 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
30-
- uses: oven-sh/setup-bun@v1
30+
with:
31+
fetch-depth: 0 # Needed to get tags
32+
- uses: oven-sh/setup-bun@v2
3133
with:
3234
bun-version: latest
3335
- name: Setup
@@ -37,13 +39,17 @@ jobs:
3739
- name: typos-action
3840
uses: crate-ci/typos@v1.17.2
3941
- name: Lint
42+
run: bun lint
43+
- name: Check version
44+
shell: bash
4045
run: |
41-
bun lint
4246
# check for version changes
4347
./update-version.sh
44-
if [[ `git status --porcelain` ]]; then
45-
echo "Version mismatch. Please run ./update-version.sh"
48+
# Check if any changes were made in README.md files
49+
if [[ -n "$(git status --porcelain -- '**/README.md')" ]]; then
50+
echo "Version mismatch detected. Please run ./update-version.sh and commit the updated README.md files."
51+
git diff -- '**/README.md'
4652
exit 1
4753
else
48-
echo "No changes detected."
54+
echo "No version mismatch detected. All versions are up to date."
4955
fi

.github/workflows/update-readme.yaml

-42
This file was deleted.

cursor/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Uses the [Coder Remote VS Code Extension](https://github.com/coder/cursor-coder)
1616
```tf
1717
module "cursor" {
1818
source = "registry.coder.com/modules/cursor/coder"
19-
version = "1.0.18"
19+
version = "1.0.19"
2020
agent_id = coder_agent.example.id
2121
}
2222
```
@@ -28,7 +28,7 @@ module "cursor" {
2828
```tf
2929
module "cursor" {
3030
source = "registry.coder.com/modules/cursor/coder"
31-
version = "1.0.18"
31+
version = "1.0.19"
3232
agent_id = coder_agent.example.id
3333
folder = "/home/coder/project"
3434
}

jupyter-notebook/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A module that adds Jupyter Notebook in your Coder template.
1616
```tf
1717
module "jupyter-notebook" {
1818
source = "registry.coder.com/modules/jupyter-notebook/coder"
19-
version = "1.0.8"
19+
version = "1.0.19"
2020
agent_id = coder_agent.example.id
2121
}
2222
```

jupyterlab/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A module that adds JupyterLab in your Coder template.
1616
```tf
1717
module "jupyterlab" {
1818
source = "registry.coder.com/modules/jupyterlab/coder"
19-
version = "1.0.8"
19+
version = "1.0.19"
2020
agent_id = coder_agent.example.id
2121
}
2222
```

update-version.sh

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
#!/usr/bin/env bash
22

3-
# This script updates the version number in the README.md files of all modules
4-
# to the latest tag in the repository. It is intended to be run from the root
3+
# This script increments the version number in the README.md files of all modules
4+
# by 1 patch version. It is intended to be run from the root
55
# of the repository or by using the `bun update-version` command.
66

77
set -euo pipefail
88

99
current_tag=$(git describe --tags --abbrev=0)
10-
previous_tag=$(git describe --tags --abbrev=0 $current_tag^)
11-
mapfile -t changed_dirs < <(git diff --name-only "$previous_tag"..."$current_tag" -- ':!**/README.md' ':!**/*.test.ts' | xargs dirname | grep -v '^\.' | sort -u)
1210

13-
LATEST_TAG=$(git describe --abbrev=0 --tags | sed 's/^v//') || exit $?
11+
# Increment the patch version
12+
LATEST_TAG=$(echo "$current_tag" | sed 's/^v//' | awk -F. '{print $1"."$2"."$3+1}') || exit $?
1413

14+
# List directories with changes that are not README.md or test files
15+
mapfile -t changed_dirs < <(git diff --name-only "$current_tag" -- ':!**/README.md' ':!**/*.test.ts' | xargs dirname | grep -v '^\.' | sort -u)
16+
17+
echo "Directories with changes: ${changed_dirs[*]}"
18+
19+
# Iterate over directories and update version in README.md
1520
for dir in "${changed_dirs[@]}"; do
1621
if [[ -f "$dir/README.md" ]]; then
17-
echo "Bumping version in $dir/README.md"
1822
file="$dir/README.md"
1923
tmpfile=$(mktemp /tmp/tempfile.XXXXXX)
2024
awk -v tag="$LATEST_TAG" '{
@@ -25,5 +29,12 @@ for dir in "${changed_dirs[@]}"; do
2529
print
2630
}
2731
}' "$file" > "$tmpfile" && mv "$tmpfile" "$file"
32+
33+
# Check if the README.md file has changed
34+
if ! git diff --quiet -- "$dir/README.md"; then
35+
echo "Bumping version in $dir/README.md from $current_tag to $LATEST_TAG (incremented)"
36+
else
37+
echo "Version in $dir/README.md is already up to date"
38+
fi
2839
fi
2940
done

0 commit comments

Comments
 (0)