|
| 1 | +name: 'Format version' |
| 2 | +author: 'Pete Sramek' |
| 3 | +description: 'Formats versions.' |
| 4 | +inputs: |
| 5 | +# Required |
| 6 | + version: |
| 7 | + description: 'Version to use.' |
| 8 | + required: true |
| 9 | + patch: |
| 10 | + description: 'Patch version to append to the formatted version.' |
| 11 | + required: true |
| 12 | + commit-delta: |
| 13 | + description: 'Commit delta to append to the formatted version.' |
| 14 | + required: true |
| 15 | + commit-sha: |
| 16 | + description: 'Commit SHA to append to the formatted version.' |
| 17 | + required: true |
| 18 | + pre-release-tag: |
| 19 | + description: 'Pre-release tag to append to the formatted version.' |
| 20 | + required: true |
| 21 | +# Optional |
| 22 | + dotnet_sdk_version: |
| 23 | + description: '.NET SDK version. Default: ''9.x''' |
| 24 | + required: false |
| 25 | + default: '9.x' |
| 26 | + |
| 27 | +outputs: |
| 28 | + friendly-version: |
| 29 | + description: 'Version extracted from the branch name.' |
| 30 | + value: ${{ steps.regex-match.outputs.match }} |
| 31 | + assembly-version: |
| 32 | + description: 'Formatted version.' |
| 33 | + value: ${{ steps.format-version.outputs.assembly-version }} |
| 34 | + assembly-informational-version: |
| 35 | + description: 'Formatted assembly informational version.' |
| 36 | + value: ${{ steps.format-version.outputs.assembly-informational-version }} |
| 37 | + file-version: |
| 38 | + description: 'Formatted file version.' |
| 39 | + value: ${{ steps.format-version.outputs.file-version }} |
| 40 | + package-version: |
| 41 | + description: 'Formatted package version.' |
| 42 | + value: ${{ steps.format-version.outputs.package-version }} |
| 43 | + |
| 44 | +runs: |
| 45 | + using: "composite" |
| 46 | + steps: |
| 47 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 48 | + uses: actions/checkout@v5 |
| 49 | + |
| 50 | + - name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}' |
| 51 | + uses: actions/setup-dotnet@v4 |
| 52 | + with: |
| 53 | + dotnet-version: ${{ inputs.dotnet_sdk_version }} |
| 54 | + - name: 'Format version' |
| 55 | + shell: bash |
| 56 | + id: format-version |
| 57 | + run: | |
| 58 | + echo "friendly-version=${{ inputs.version }}" >> $GITHUB_OUTPUT |
| 59 | + echo "assembly-version=${{ inputs.version }}.${{ inputs.patch }}.${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT |
| 60 | + echo "assembly-informational-version=${{ inputs.version }}.${{ inputs.patch }}+${{ inputs.commit-sha }}" >> $GITHUB_OUTPUT |
| 61 | + echo "file-version=${{ inputs.version }}.${{ inputs.patch }}.${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT |
| 62 | + if [ -n "${{ inputs.prerelease-tag }}" ]; then |
| 63 | + echo "package-version=${{ inputs.version }}.${{ inputs.patch }}-${{ inputs.pre-release-tag }}-${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT |
| 64 | + else |
| 65 | + echo "package-version=${{ inputs.version }}.${{ inputs.patch }}.${{ inputs.commit-delta }}" >> $GITHUB_OUTPUT |
| 66 | + fi |
0 commit comments