Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/actions/semantic-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Semantic version"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update build-dotnet-app.yml file within this PR so that we can test this action in practice

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to define action output

outputs:
  name:
    description: Determined semantic version number
    value: ${{ steps.version.outputs.number }}

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 }}