cloudflare/kumo

Public

mirrored from https://github.com/cloudflare/kumoAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
main

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ci/versioning/version-beta.sh

34lines · modecode

1#!/bin/bash
2set -euo pipefail
3
4# Note: Ensure "jq" is installed - sudo apt-get update && sudo apt-get install -y jq
5# Note: Ensure Git is configured - git config --global user.email "you@example.com" && git config --global user.name "Your Name"
6# Note: Use CI vars where possible: `commitHash=${GITHUB_SHA:0:7:-$(git rev-parse --short HEAD)}`
7# - This line first tries to use the GITHUB_SHA environment variable (GitHub Actions) and falls back to the Git command if it's not set.
8
9# Run changeset version to version all packages
10pnpm run version
11
12# Ensure changes are staged for the commit hash to reflect all changes including version bumps
13git add .
14
15# Get the current short Git commit hash
16# GitHub Actions provides GITHUB_SHA (full), so we truncate it
17commitHash=${GITHUB_SHA:+${GITHUB_SHA:0:7}}
18commitHash=${commitHash:-$(git rev-parse --short HEAD)}
19
20# Find all modified package.json files and append "-beta" and the commit hash to their version
21git diff --cached --name-only | grep 'package.json$' | while read -r file ; do
22 echo "Updating $file with \"-beta\" and commit hash $commitHash"
23
24 # Use jq to safely read and modify the JSON data, appending "-beta" and the commit hash to the version
25 jq --arg hash "$commitHash" '
26 if .version then
27 .version += ("-beta." + $hash)
28 else
29 .
30 end' "$file" > temp.json && mv temp.json "$file"
31
32 # Stage the modified package.json for commit
33 git add "$file"
34done
35