Skip to content

Update test.yml

Update test.yml #18

Workflow file for this run

name: Test Increment Semantic Version
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test-action:
runs-on: ubuntu-latest
strategy:
matrix:
# Define the release types and their expected versions
include:
# Major, Minor, and Patch increments
- { current-version: "1.0.0", version-fragment: "major", expected-version: "2.0.0" }
- { current-version: "1.0.0", version-fragment: "minor", expected-version: "1.1.0" }
- { current-version: "1.0.0", version-fragment: "patch", expected-version: "1.0.1" }
- { current-version: "2.11.7", version-fragment: "major", expected-version: "3.0.0" }
- { current-version: "v2.11.7", version-fragment: "major", expected-version: "3.0.0" }
- { current-version: "2.11.7-alpha.3", version-fragment: "major", expected-version: "3.0.0" }
# Pre-Version increments from stable
- { current-version: "1.0.0", version-fragment: "alpha", expected-version: "1.0.1-alpha.0" }
- { current-version: "1.0.0", version-fragment: "beta", expected-version: "1.0.1-beta.0" }
- { current-version: "1.0.0", version-fragment: "rc", expected-version: "1.0.1-rc.0" }
# Pre-Version increments from existing pre-versions without increment
- { current-version: "1.0.1-alpha", version-fragment: "alpha", expected-version: "1.0.1-alpha.1" }
- { current-version: "1.0.1-beta", version-fragment: "beta", expected-version: "1.0.1-beta.1" }
- { current-version: "1.0.1-rc", version-fragment: "rc", expected-version: "1.0.1-rc.1" }
# Pre-Version increments from existing pre-versions with increment 0
- { current-version: "1.0.1-alpha.0", version-fragment: "alpha", expected-version: "1.0.1-alpha.1" }
- { current-version: "1.0.1-beta.0", version-fragment: "beta", expected-version: "1.0.1-beta.1" }
- { current-version: "1.0.1-rc.0", version-fragment: "rc", expected-version: "1.0.1-rc.1" }
# Pre-Version increments from existing pre-versions with increment >= 1
- { current-version: "1.0.1-alpha.1", version-fragment: "alpha", expected-version: "1.0.1-alpha.2" }
- { current-version: "1.0.1-beta.2", version-fragment: "beta", expected-version: "1.0.1-beta.3" }
- { current-version: "1.0.1-rc.3", version-fragment: "rc", expected-version: "1.0.1-rc.4" }
# Transition between different pre-version types
- { current-version: "1.0.1-alpha.1", version-fragment: "beta", expected-version: "1.0.1-beta.1" }
- { current-version: "1.0.1-beta.1", version-fragment: "rc", expected-version: "1.0.1-rc.1" }
# Transition from pre-version to stable
- { current-version: "1.0.1-alpha.1", version-fragment: "stable", expected-version: "1.0.1" }
- { current-version: "1.0.1-beta.1", version-fragment: "stable", expected-version: "1.0.1" }
- { current-version: "1.0.1-rc.1", version-fragment: "stable", expected-version: "1.0.1" }
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Test action
id: increment-version
uses: ./
with:
current-version: ${{ matrix.current-version }}
version-fragment: ${{ matrix.version-fragment }}
- name: Validate next version
run: |
EXPECTED_VERSION="${{ matrix.expected-version }}"
if [ "${{ steps.increment-version.outputs.next-version }}" != "$EXPECTED_VERSION" ]; then
echo "Validation failed! Expected $EXPECTED_VERSION but got ${{ steps.increment-version.outputs.next-version }}."
exit 1
else
echo "Validation passed! Next version is $EXPECTED_VERSION as expected."
fi