Skip to content

Commit bd6747f

Browse files
authored
chore: move update-version to ci (#301)
1 parent fb81c89 commit bd6747f

File tree

7 files changed

+39
-55
lines changed

7 files changed

+39
-55
lines changed

.github/workflows/ci.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0 # Needed to get tags
3032
- uses: oven-sh/setup-bun@v2
3133
with:
3234
bun-version: latest
@@ -38,3 +40,16 @@ jobs:
3840
uses: crate-ci/[email protected]
3941
- name: Lint
4042
run: bun lint
43+
- name: Check version
44+
shell: bash
45+
run: |
46+
# check for version changes
47+
./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'
52+
exit 1
53+
else
54+
echo "No version mismatch detected. All versions are up to date."
55+
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
}

filebrowser/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A file browser for your workspace.
1414
```tf
1515
module "filebrowser" {
1616
source = "registry.coder.com/modules/filebrowser/coder"
17-
version = "1.0.18"
17+
version = "1.0.19"
1818
agent_id = coder_agent.example.id
1919
}
2020
```
@@ -28,7 +28,7 @@ module "filebrowser" {
2828
```tf
2929
module "filebrowser" {
3030
source = "registry.coder.com/modules/filebrowser/coder"
31-
version = "1.0.18"
31+
version = "1.0.19"
3232
agent_id = coder_agent.example.id
3333
folder = "/home/coder/project"
3434
}
@@ -39,7 +39,7 @@ module "filebrowser" {
3939
```tf
4040
module "filebrowser" {
4141
source = "registry.coder.com/modules/filebrowser/coder"
42-
version = "1.0.18"
42+
version = "1.0.19"
4343
agent_id = coder_agent.example.id
4444
database_path = ".config/filebrowser.db"
4545
}

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)