Skip to content

Commit

Permalink
new fixes merged into one commit
Browse files Browse the repository at this point in the history
  • Loading branch information
asheliahut authored and christian-draeger committed Nov 21, 2024
1 parent fc0090f commit a430fd3
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 42 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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
release-type:
- { version-fragment: "major", expected-version: "2.0.0" }
- { version-fragment: "feature", expected-version: "1.1.0" }
- { version-fragment: "minor", expected-version: "1.1.0" }
- { version-fragment: "bug", expected-version: "1.0.1" }
- { version-fragment: "patch", expected-version: "1.0.1" }
- { version-fragment: "hotfix", expected-version: "1.0.1" }
- { version-fragment: "alpha", expected-version: "1.0.0-alpha.0" }
- { version-fragment: "beta", expected-version: "1.0.0-beta.0" }
- { version-fragment: "rc", expected-version: "1.0.0-rc.0" }

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test action
id: increment-version
uses: ./
with:
current-version: 1.0.0
version-fragment: ${{ matrix.release-type.version-fragment }}

- name: Validate next version
run: |
EXPECTED_VERSION="${{ matrix.release-type.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
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

66 changes: 39 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ This is a GitHub action to bump a given semantic version, depending on a given v

**Required** The versions fragment you want to increment.

Possible options are **[ major | feature | bug | alpha | beta | pre | rc ]**
Possible options are **[ major | feature | minor | bug | patch | hotfix | alpha | beta | pre | rc ]**

Note: [feature | minor] and [bug | patch | hotfix] are synonyms.

## Outputs

Expand All @@ -34,30 +36,40 @@ The incremented version.
## input / output Examples

| version-fragment | current-version | | output |
| ---------------- | --------------- | - | -------------- |
| major | 2.11.7 | | 3.0.0 |
| major | v2.11.7 | | 3.0.0 |
| major | 2.11.7-alpha3 | | 3.0.0 |
| major | 2.11.7-alpha.3 | | 3.0.0 |
| feature | 2.11.7 | | 2.12.0 |
| feature | 2.11.7-alpha3 | | 2.12.0 |
| feature | 2.11.7-alpha.3 | | 2.12.0 |
| bug | 2.11.7 | | 2.11.8 |
| bug | 2.11.7-alpha3 | | 2.11.8 |
| bug | 2.11.7-alpha.3 | | 2.11.8 |
| alpha | 2.11.7 | | 2.11.7-alpha.1 |
| alpha | 2.11.7-alpha3 | | 2.11.7-alpha.4 |
| alpha | 2.11.7-alpha.3 | | 2.11.7-alpha.4 |
| beta | 2.11.7 | | 2.11.7-beta.1 |
| beta | 2.11.7-alpha3 | | 2.11.7-beta.1 |
| beta | 2.11.7-alpha.3 | | 2.11.7-beta.1 |
| pre | 2.11.7 | | 2.11.7-pre.1 |
| pre | 2.11.7-alpha3 | | 2.11.7-pre.1 |
| pre | 2.11.7-alpha.3 | | 2.11.7-pre.1 |
| rc | 2.11.7 | | 2.11.7-rc.1 |
| rc | 2.11.7-alpha3 | | 2.11.7-rc.1 |
| rc | 2.11.7-alpha.3 | | 2.11.7-rc.1 |

# License
| version-fragment | current-version | output |
|------------------|-----------------|----------------|
| major | 2.11.7 | 3.0.0 |
| major | v2.11.7 | 3.0.0 |
| major | 2.11.7-alpha3 | 3.0.0 |
| major | 2.11.7-alpha.3 | 3.0.0 |
| feature | 2.11.7 | 2.12.0 |
| feature | 2.11.7-alpha3 | 2.12.0 |
| feature | 2.11.7-alpha.3 | 2.12.0 |
| minor | 2.11.7 | 2.12.0 |
| minor | 2.11.7-alpha3 | 2.12.0 |
| minor | 2.11.7-alpha.3 | 2.12.0 |
| bug | 2.11.7 | 2.11.8 |
| bug | 2.11.7-alpha3 | 2.11.8 |
| bug | 2.11.7-alpha.3 | 2.11.8 |
| patch | 2.11.7 | 2.11.8 |
| patch | 2.11.7-alpha3 | 2.11.8 |
| patch | 2.11.7-alpha.3 | 2.11.8 |
| hotfix | 2.11.7 | 2.11.8 |
| hotfix | 2.11.7-alpha3 | 2.11.8 |
| hotfix | 2.11.7-alpha.3 | 2.11.8 |
| alpha | 2.11.7 | 2.11.7-alpha.1 |
| alpha | 2.11.7-alpha3 | 2.11.7-alpha.4 |
| alpha | 2.11.7-alpha.3 | 2.11.7-alpha.4 |
| beta | 2.11.7 | 2.11.7-beta.1 |
| beta | 2.11.7-alpha3 | 2.11.7-beta.1 |
| beta | 2.11.7-alpha.3 | 2.11.7-beta.1 |
| pre | 2.11.7 | 2.11.7-pre.1 |
| pre | 2.11.7-alpha3 | 2.11.7-pre.1 |
| pre | 2.11.7-alpha.3 | 2.11.7-pre.1 |
| rc | 2.11.7 | 2.11.7-rc.1 |
| rc | 2.11.7-alpha3 | 2.11.7-rc.1 |
| rc | 2.11.7-alpha.3 | 2.11.7-rc.1 |

## License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
15 changes: 9 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ inputs:
description: 'The current semantic version you want to increment'
required: true
version-fragment:
description: 'The versions fragment you want to increment. possible options are [ major | feature | bug | alpha | beta | rc ]'
description: 'The versions fragment you want to increment. possible options are [ major | feature| minor | bug | patch | hotfix | alpha | beta | rc ]'
required: true
outputs:
next-version:
description: 'The incremented version'
value: ${{ steps.bump-version.outputs.next-version }}
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.current-version }}
- ${{ inputs.version-fragment }}
using: "composite"
steps:
- name: Run entrypoint.sh
id: bump-version
shell: bash
run: |
"$GITHUB_ACTION_PATH"/entrypoint.sh "${{ inputs.current-version }}" "${{ inputs.version-fragment }}"
8 changes: 4 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ main() {
echo "could not read previous version"; exit 1
fi

possible_release_types="major feature bug alpha beta pre rc"
possible_release_types="major feature minor bug patch hotfix alpha beta pre rc"

if [[ ! ${possible_release_types[*]} =~ ${release_type} ]]; then
echo "valid argument: [ ${possible_release_types[*]} ]"; exit 1
Expand All @@ -42,9 +42,9 @@ main() {
case "$release_type" in
"major")
((++major)); minor=0; patch=0; pre="";;
"feature")
"feature"|"minor")
((++minor)); patch=0; pre="";;
"bug")
"bug"|"patch"|"hotfix")
((++patch)); pre="";;
"alpha")
if [[ -z "$preversion" ]];
Expand Down Expand Up @@ -99,7 +99,7 @@ main() {
next_version="${major}.${minor}.${patch}${pre}"
echo "create $release_type-release version: $prev_version -> $next_version"

echo "next-version=$next_version" >> $GITHUB_OUTPUT
echo "next-version=$next_version" >> "$GITHUB_OUTPUT"
}

main "$1" "$2"

0 comments on commit a430fd3

Please sign in to comment.