diff --git a/.github/actions/semantic-version/action.yml b/.github/actions/semantic-version/action.yml new file mode 100644 index 0000000..29da902 --- /dev/null +++ b/.github/actions/semantic-version/action.yml @@ -0,0 +1,26 @@ +name: "Semantic version" +description: "Configure semantic versioning based on git tags or branch names" + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Configure version + id: version + run: | + if [[ "${{ github.ref_type }}" == "tag" ]]; then + calculated_version=$(echo ${{ github.ref }} | cut -d'/' -f3) + else + IFS='.' read -r major minor patch <<< "$(git tag | sort -V | tail -n 1)" + calculated_version="${major:-0}.$((minor + 1)).0" + fi + echo "calculated_version=$calculated_version" >> $GITHUB_OUTPUT + echo "calculated_version=$calculated_version" + shell: bash + +outputs: + calculated_version: + description: Determined semantic version number + value: ${{ steps.version.outputs.calculated_version }}