From c2ec4cbfc69087d96ba5534469e5aef7e3d1a8e2 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 24 Sep 2024 23:31:41 +0500 Subject: [PATCH 1/3] chore: move update-version to ci --- .github/workflows/ci.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 960cd035..42bb857f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,4 +37,13 @@ jobs: - name: typos-action uses: crate-ci/typos@v1.17.2 - name: Lint - run: bun lint + run: | + bun lint + # check for version changes + ./update-version.sh + if [[ `git status --porcelain` ]]; then + echo "Version mismatch. Please run ./update-version.sh" + exit 1 + else + echo "No changes detected." + fi From 70e60923609e3e246369a32e31f882d83a4844b8 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Tue, 24 Sep 2024 23:56:00 +0500 Subject: [PATCH 2/3] 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 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. --- .github/dependabot.yml | 6 ++++ .github/workflows/ci.yaml | 18 ++++++++---- .github/workflows/update-readme.yaml | 42 ---------------------------- cursor/README.md | 4 +-- jupyter-notebook/README.md | 2 +- jupyterlab/README.md | 2 +- update-version.sh | 23 +++++++++++---- 7 files changed, 39 insertions(+), 58 deletions(-) create mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/update-readme.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..5ace4600 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 42bb857f..4d0c7090 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/.github/workflows/update-readme.yaml b/.github/workflows/update-readme.yaml deleted file mode 100644 index 0d0e2264..00000000 --- a/.github/workflows/update-readme.yaml +++ /dev/null @@ -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' diff --git a/cursor/README.md b/cursor/README.md index a62743be..c2997bee 100644 --- a/cursor/README.md +++ b/cursor/README.md @@ -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" } diff --git a/jupyter-notebook/README.md b/jupyter-notebook/README.md index 6338f112..83d36cb9 100644 --- a/jupyter-notebook/README.md +++ b/jupyter-notebook/README.md @@ -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 } ``` diff --git a/jupyterlab/README.md b/jupyterlab/README.md index 3d04cf36..ed73b56e 100644 --- a/jupyterlab/README.md +++ b/jupyterlab/README.md @@ -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 } ``` diff --git a/update-version.sh b/update-version.sh index 5deb63b2..b062736f 100755 --- a/update-version.sh +++ b/update-version.sh @@ -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 From 4f2126dc9f7fb154a21a834a72da41ced74b92b6 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Fri, 27 Sep 2024 23:23:10 +0500 Subject: [PATCH 3/3] Bump filebrowser module version to 1.0.19 --- filebrowser/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filebrowser/README.md b/filebrowser/README.md index e92560b0..8665d828 100644 --- a/filebrowser/README.md +++ b/filebrowser/README.md @@ -14,7 +14,7 @@ A file browser for your workspace. ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.18" + version = "1.0.19" agent_id = coder_agent.example.id } ``` @@ -28,7 +28,7 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.18" + version = "1.0.19" agent_id = coder_agent.example.id folder = "/home/coder/project" } @@ -39,7 +39,7 @@ module "filebrowser" { ```tf module "filebrowser" { source = "registry.coder.com/modules/filebrowser/coder" - version = "1.0.18" + version = "1.0.19" agent_id = coder_agent.example.id database_path = ".config/filebrowser.db" }