|
| 1 | +name: 'Determine version' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + # Required |
| 7 | + config-file-path: |
| 8 | + description: 'Path to the configuration file.' |
| 9 | + type: string |
| 10 | + required: true |
| 11 | + run-number: |
| 12 | + description: 'The run number of the parent workflow.' |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + # Optional |
| 16 | + dotnet-sdk-version: |
| 17 | + description: 'Version of the .NET SDK to use. Default: ''9.0.x''.' |
| 18 | + type: string |
| 19 | + required: false |
| 20 | + default: '9.0.x' |
| 21 | + gitversion-version: |
| 22 | + description: 'Version of GitVersion to use. Default: ''6.1.x''.' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + default: '6.1.x' |
| 26 | + prerelease-tag: |
| 27 | + description: 'The prerelease tag to use. Default: ''''.' |
| 28 | + type: string |
| 29 | + required: false |
| 30 | + default: '' |
| 31 | + outputs: |
| 32 | + friendly-version: |
| 33 | + description: "The friedly version." |
| 34 | + value: ${{ jobs.version.outputs.friendly-version }} |
| 35 | + assembly-version: |
| 36 | + description: "The assembly version." |
| 37 | + value: ${{ jobs.version.outputs.assembly-version }} |
| 38 | + assembly-informational-version: |
| 39 | + description: "The assembly informational version." |
| 40 | + value: ${{ jobs.version.outputs.assembly-informational-version }} |
| 41 | + file-version: |
| 42 | + description: "The file version." |
| 43 | + value: ${{ jobs.version.outputs.file-version }} |
| 44 | + package-version: |
| 45 | + description: "The package version." |
| 46 | + value: ${{ jobs.version.outputs.package-version }} |
| 47 | + |
| 48 | +jobs: |
| 49 | + version: |
| 50 | + name: 'Version' |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + outputs: |
| 54 | + friendly-version: ${{ env.friendly-version }} |
| 55 | + assembly-version: ${{ env.assembly-version }} |
| 56 | + assembly-informational-version: ${{ env.assembly-informational-version }} |
| 57 | + file-version: ${{ env.file-version }} |
| 58 | + package-version: ${{ env.package-version }} |
| 59 | + |
| 60 | + steps: |
| 61 | + |
| 62 | + - name: 'Checkout ${{ github.head_ref || github.ref }}' |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + fetch-depth: 0 |
| 66 | + |
| 67 | + - name: 'Setup GitVersion ${{ env.git-version }}' |
| 68 | + uses: gittools/actions/gitversion/setup@v4.1.0 |
| 69 | + with: |
| 70 | + versionSpec: ${{ inputs.gitversion-version }} |
| 71 | + preferLatestVersion: true |
| 72 | + |
| 73 | + - name: 'Determine version' |
| 74 | + id: gitversion |
| 75 | + uses: gittools/actions/gitversion/execute@v4.1.0 |
| 76 | + with: |
| 77 | + configFilePath: ${{ inputs.config-file-path }} |
| 78 | + |
| 79 | + - name: 'Set friendly version' |
| 80 | + shell: bash |
| 81 | + run: echo "friendly-version=${{ steps.gitversion.outputs.assemblySemVer }}" >> $GITHUB_ENV |
| 82 | + |
| 83 | + - name: 'Set assembly version' |
| 84 | + shell: bash |
| 85 | + run: echo "assembly-version=${{ steps.gitversion.outputs.assemblySemVer }}.${{ inputs.run-number }}.${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" >> $GITHUB_ENV |
| 86 | + |
| 87 | + - name: 'Set assembly informational version' |
| 88 | + shell: bash |
| 89 | + run: echo "assembly-informational-version=${{ steps.gitversion.outputs.assemblySemVer }}.${{ inputs.run-number }}+${{ steps.gitversion.outputs.sha }}" >> $GITHUB_ENV |
| 90 | + |
| 91 | + - name: 'Set file version' |
| 92 | + shell: bash |
| 93 | + run: echo "file-version=${{ steps.gitversion.outputs.AssemblySemFileVer }}.${{ inputs.run-number }}.${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" >> $GITHUB_ENV |
| 94 | + |
| 95 | + - if: ${{ steps.gitversion.outputs.PreReleaseLabelWithDash == '' }} |
| 96 | + name: 'Set package version' |
| 97 | + shell: bash |
| 98 | + run: echo "package-version=${{ steps.gitversion.outputs.AssemblySemVer }}.${{ inputs.run-number }}" >> $GITHUB_ENV |
| 99 | + |
| 100 | + - if: ${{ steps.gitversion.outputs.PreReleaseLabelWithDash != '' }} |
| 101 | + name: 'Set package version' |
| 102 | + shell: bash |
| 103 | + run: echo "package-version=${{ steps.gitversion.outputs.AssemblySemVer }}.${{ inputs.run-number }}-${{ steps.gitversion.outputs.PreReleaseLabel }}-${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" >> $GITHUB_ENV |
0 commit comments