|
78 | 78 | ref: ${{ github.sha }} |
79 | 79 | path: ${{ env.CLONE_FOLDER }} |
80 | 80 | submodules: recursive |
| 81 | + - name: Tag commit on production |
| 82 | + run: | |
| 83 | + # Enter folder with repository. |
| 84 | + Push-Location "$($ENV:CLONE_FOLDER)"; |
| 85 | +
|
| 86 | + # Get current version from configuration file. |
| 87 | + $confFile = Get-Content "./doc/conf.py" -Encoding utf8 -Raw; |
| 88 | + $confMatch = $confFile -Match 'version[\s]*=[\s]*"([0-9]+\.[0-9]+\.[0-9]+)"[\s]*'; |
| 89 | + if ($confMatch -eq $false) { throw "Unable to retrieve version from configuration file..."; } |
| 90 | + $currVersion = $Matches[1]; |
| 91 | +
|
| 92 | + # Attempt to tag only on 'production' kind of deployments. |
| 93 | + if ('${{ inputs.deploy }}' -eq "production") |
| 94 | + { |
| 95 | + # Fetch all tags from remote. |
| 96 | + git fetch --tags --force; |
| 97 | + if ($LastExitCode -ne 0) { throw "Unable to fetch tags from repository."; } |
| 98 | +
|
| 99 | + # Check if current commit is already tagged, in which case skip it. |
| 100 | + $out = git tag -l -n0 --points-at "${{ github.sha }}"; |
| 101 | + if ($LastExitCode -ne 0) { throw "Unable to determine if current commit is tagged."; } |
| 102 | + if ($out.Length -eq 0) |
| 103 | + { |
| 104 | + $out = git tag -l -n0 "$currVersion"; |
| 105 | + if ($LastExitCode -ne 0) { throw "Unable to determine if tag exists for version."; } |
| 106 | + if ($out.Length -ne 0) { throw "Version '$out' is already tagged."; } |
| 107 | +
|
| 108 | + # Create tag locally for documentation and other purposes, do not push, would need perms. |
| 109 | + git tag "$currVersion" "${{ github.sha }}"; |
| 110 | + if ($LastExitCode -ne 0) { throw "Unable to create tag '$currVersion' for '${{ github.sha }}'"; } |
| 111 | + } |
| 112 | + else |
| 113 | + { |
| 114 | + Write-Host "Commit '${{ github.sha }}' is already tagged..."; |
| 115 | + } |
| 116 | + } |
| 117 | + else |
| 118 | + { |
| 119 | + Write-Host "No tagging necessary for '${{ inputs.deploy }}' deployment..."; |
| 120 | + } |
| 121 | +
|
| 122 | + # Return to original folder. |
| 123 | + Pop-Location; |
81 | 124 | - name: Build every target with CMake |
82 | 125 | run: | |
83 | 126 | # Enter Python virtual environment. |
@@ -115,7 +158,6 @@ jobs: |
115 | 158 | tar ` |
116 | 159 | --exclude="*.obj" ` |
117 | 160 | --exclude="*.o" ` |
118 | | - --exclude="*.pdf" ` |
119 | 161 | --exclude="$($cfg.Name)/.git" ` |
120 | 162 | -cf "$($cfg.Name).repo.tar.gz" "$($cfg.Name)"; |
121 | 163 | if ($LastExitCode -ne 0) { throw "$($cfg.Name): Compressing the repository failed with error '$LastExitCode'." } |
|
0 commit comments