7 changed files with 185 additions and 5 deletions
@ -1,14 +1,40 @@ |
|||||||
# Version Bump Action |
# Version Bump Action |
||||||
|
|
||||||
A Github Action that will replace versions in JSON, PLIST, YAML, and XML files. |
A Github Action that will replace versions in JSON, PLIST, YAML, TOML, and XML files. |
||||||
Specifically created for interacting with AndroidManifest, iOS development plists, Helm Charts, and Node package JSON files. |
Specifically created for interacting with AndroidManifest, iOS development plists, Helm Charts, Rust Cargo manifests, and Node package JSON files. |
||||||
|
|
||||||
|
**Supported file types:** |
||||||
|
- JSON: `package.json`, `package-lock.json` (updates `version` and `packages[""].version`) |
||||||
|
- PLIST: iOS Info.plist files |
||||||
|
- XML: AndroidManifest.xml, .NET project files (.csproj, .props) |
||||||
|
- YAML: Helm Chart.yaml files |
||||||
|
- TOML: Cargo.toml files (updates `[package].version` only) |
||||||
|
|
||||||
## Usage |
## Usage |
||||||
|
|
||||||
```yml |
```yml |
||||||
- name: Bump Android Version |
- name: Bump Android Version |
||||||
uses: ./version-bump |
uses: ./version-bump |
||||||
with: |
with: |
||||||
version: ${{ inputs.version_number }} |
version: ${{ inputs.version_number }} |
||||||
file_path: "./AndroidManifest.xml" |
file_path: "./AndroidManifest.xml" |
||||||
``` |
``` |
||||||
|
|
||||||
|
## Local Testing |
||||||
|
|
||||||
|
To build and test the Docker action locally, use the `test-local.sh` script: |
||||||
|
|
||||||
|
```bash |
||||||
|
# Test with default version (2123.4.5) |
||||||
|
./test-local.sh |
||||||
|
|
||||||
|
# Test with a specific version |
||||||
|
./test-local.sh 2024.1.0 |
||||||
|
``` |
||||||
|
|
||||||
|
This script will: |
||||||
|
|
||||||
|
1. Build the Docker image locally |
||||||
|
2. Run the action against all test fixtures in `tests/fixtures/` in a copied directory |
||||||
|
3. Verify that version updates were applied correctly |
||||||
|
4. Display a summary of changes |
||||||
|
|||||||
@ -0,0 +1,110 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
# test-local.sh - Build and test the version-bump Docker action locally |
||||||
|
# This script builds the Docker image and runs it against all test fixtures |
||||||
|
|
||||||
|
set -e |
||||||
|
|
||||||
|
# Color output (only if terminal supports it) |
||||||
|
if [[ -t 1 ]]; then |
||||||
|
RED='\033[0;31m' |
||||||
|
GREEN='\033[0;32m' |
||||||
|
YELLOW='\033[1;33m' |
||||||
|
NC='\033[0m' |
||||||
|
else |
||||||
|
RED='' |
||||||
|
GREEN='' |
||||||
|
YELLOW='' |
||||||
|
NC='' |
||||||
|
fi |
||||||
|
|
||||||
|
# Get the directory where this script is located |
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
||||||
|
cd "$SCRIPT_DIR" |
||||||
|
|
||||||
|
# Default version to use for testing |
||||||
|
VERSION="${1:-2123.4.5}" |
||||||
|
|
||||||
|
echo -e "${YELLOW}=== Version Bump Docker Action Test ===${NC}" |
||||||
|
echo "Testing with version: $VERSION" |
||||||
|
echo "" |
||||||
|
|
||||||
|
# Build the Docker image |
||||||
|
DOCKER_TAG="version-bump:test" |
||||||
|
echo -e "${YELLOW}Building Docker image...${NC}" |
||||||
|
docker build -t "$DOCKER_TAG" . |
||||||
|
echo -e "${GREEN}✓ Docker image built successfully${NC}" |
||||||
|
echo "" |
||||||
|
|
||||||
|
# Create a temporary directory for test files |
||||||
|
TEST_DIR="$SCRIPT_DIR/tmp-$(date +%s)" |
||||||
|
mkdir -p "$TEST_DIR" |
||||||
|
echo "Using temporary directory: $TEST_DIR" |
||||||
|
|
||||||
|
# Copy test fixtures to temp directory |
||||||
|
ORIGINAL_TEST_DIR="$SCRIPT_DIR/tests/fixtures" |
||||||
|
cp -r "$ORIGINAL_TEST_DIR/"* "$TEST_DIR/" |
||||||
|
|
||||||
|
# Function to run a test |
||||||
|
run_test() { |
||||||
|
local file_name="$1" |
||||||
|
local file_path="$TEST_DIR/$file_name" |
||||||
|
|
||||||
|
echo -e "${YELLOW}Testing: $file_name${NC}" |
||||||
|
|
||||||
|
# Create a temporary file for GitHub output |
||||||
|
GITHUB_OUTPUT_NAME=".github_output" |
||||||
|
GITHUB_OUTPUT="$TEST_DIR/$GITHUB_OUTPUT_NAME" |
||||||
|
CONTAINER_WORKSPACE="/workspace" |
||||||
|
|
||||||
|
# Run the Docker container |
||||||
|
docker run --rm \ |
||||||
|
-v "$TEST_DIR:$CONTAINER_WORKSPACE" \ |
||||||
|
-e INPUT_VERSION="$VERSION" \ |
||||||
|
-e INPUT_FILE_PATH="$CONTAINER_WORKSPACE/$file_name" \ |
||||||
|
-e GITHUB_OUTPUT="$CONTAINER_WORKSPACE/$GITHUB_OUTPUT_NAME" \ |
||||||
|
"$DOCKER_TAG" |
||||||
|
|
||||||
|
# Check if the file was modified |
||||||
|
if grep -q "$VERSION" "$file_path"; then |
||||||
|
echo -e "${GREEN}✓ $file_name updated successfully${NC}" |
||||||
|
|
||||||
|
# Show the changes |
||||||
|
echo " Changes in $file_name:" |
||||||
|
grep -n "$VERSION" "$file_path" | head -3 | sed 's/^/ /' |
||||||
|
else |
||||||
|
echo -e "${RED}✗ $file_name was not updated${NC}" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
# Clean up |
||||||
|
echo " GITHUB_OUTPUT:" |
||||||
|
echo " $(cat "$GITHUB_OUTPUT")" |
||||||
|
rm -f "$GITHUB_OUTPUT" |
||||||
|
echo "" |
||||||
|
} |
||||||
|
|
||||||
|
# Run tests for each fixture file |
||||||
|
echo -e "${YELLOW}=== Running Tests ===${NC}" |
||||||
|
echo "" |
||||||
|
|
||||||
|
run_test "package-lock.json" |
||||||
|
run_test "Info.plist" |
||||||
|
run_test "AndroidManifest.xml" |
||||||
|
run_test "dir.build.props" |
||||||
|
run_test "test.csproj" |
||||||
|
run_test "Cargo.toml" |
||||||
|
run_test "Chart.yaml" |
||||||
|
|
||||||
|
# Show git diff style output |
||||||
|
echo -e "${YELLOW}=== File Changes Summary ===${NC}" |
||||||
|
for file in "$TEST_DIR"/*; do |
||||||
|
if [[ -f "$file" && $(basename "$file") != ".gitignore" ]]; then |
||||||
|
echo -e "${YELLOW}$(basename "$file"):${NC}" |
||||||
|
grep -n "$VERSION" "$file" | head -2 | sed 's/^/ /' |
||||||
|
fi |
||||||
|
done |
||||||
|
|
||||||
|
echo "" |
||||||
|
echo -e "${GREEN}=== All Tests Passed! ===${NC}" |
||||||
|
echo -e "${GREEN}The Docker image works correctly with version: $VERSION${NC}" |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
[package] |
||||||
|
name = "some-project" |
||||||
|
version = "0.1.0" |
||||||
|
edition = "2021" |
||||||
|
|
||||||
|
[dependencies] |
||||||
|
|
||||||
|
[profile.release] |
||||||
|
strip = true |
||||||
Loading…
Reference in new issue