Skip to content

Commit 4ebc258

Browse files
authored
Merge pull request #39 from wintoncode/fix-version-and-push
Fixed versioning and NuGet push
2 parents 41381b4 + 775c393 commit 4ebc258

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

.github/workflows/dotnet.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,29 @@ jobs:
2323
dotnet-version: 5.x
2424
- name: Version
2525
if: ${{ github.event_name != 'pull_request' }}
26-
run: ./etc/scripts/write_version_targets.sh
26+
run: etc/scripts/write_version_targets.sh
27+
shell: bash
2728
- name: Restore dependencies
2829
run: >
2930
dotnet restore
3031
- name: Build
3132
run: >
3233
dotnet build
3334
--no-restore --configuration Release --framework netstandard2.0
34-
./Winton.Extensions.Threading.Actor/Winton.Extensions.Threading.Actor.csproj
35+
Winton.Extensions.Threading.Actor/Winton.Extensions.Threading.Actor.csproj
3536
- name: Test
3637
run: >
3738
dotnet test
3839
--no-restore --verbosity normal --configuration Release --framework net5.0
39-
./Winton.Extensions.Threading.Actor.Tests.Unit/Winton.Extensions.Threading.Actor.Tests.Unit.csproj
40+
Winton.Extensions.Threading.Actor.Tests.Unit/Winton.Extensions.Threading.Actor.Tests.Unit.csproj
4041
- name: Pack
41-
if: ${{ matrix.os == 'windows-latest' }}
42+
if: ${{ startsWith(matrix.os, 'windows-') }}
4243
run: >
4344
dotnet pack
44-
--no-build --no-restore --configuration Release --output ..
45-
./Winton.Extensions.Threading.Actor/Winton.Extensions.Threading.Actor.csproj
45+
--no-build --no-restore --configuration Release --output .
46+
Winton.Extensions.Threading.Actor/Winton.Extensions.Threading.Actor.csproj
4647
- name: Push
47-
if: ${{ matrix.os == 'windows-latest' && github.event_name == 'release' }}
48+
if: ${{ startsWith(matrix.os, 'windows-') && github.event_name == 'release' }}
4849
run: >
4950
dotnet nuget push
50-
./*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}}
51+
*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}}

etc/scripts/calculate_file_version.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,27 @@ esac;
2626
# will set branch to the version number. This will mean that below the branch is
2727
# treated as a release no matter what the true name of the branch is.
2828
# 2. Failing that, try to get the branch name using symbolic-ref
29-
# 3. ... but that won't work for detached heads so first try TRAVIS_BRANCH in case we're on Travis
30-
# 4. ... and if this isn't Travis try Appveyor
31-
# 4. ... and if this isn't Appveyor try to use git describe to get something even if it's just a sha
32-
# 5. ... but sometimes despite the --always, even that will fail so just output the commitish.
33-
branch="$($GIT describe --tags --exact-match --match='[0-9]*.[0-9]*.[0-9]*' $commitish 2>/dev/null || $GIT symbolic-ref -q --short HEAD || echo ${TRAVIS_BRANCH:-})";
34-
35-
if [[ -z $branch ]]; then
36-
branch="${APPVEYOR_REPO_BRANCH}"
37-
fi;
38-
29+
# 3. ... but that won't work for detached heads so first try GITHUB_REF
30+
# 4. ... else try to use git describe to get something even if it's just a sha
31+
# 5. ... but sometimes despite the --always, even that will fail so just output the commitish
32+
branch="$($GIT describe --tags --exact-match --match='[0-9]*.[0-9]*.[0-9]*' $commitish 2>/dev/null || $GIT symbolic-ref -q --short HEAD || echo ${GITHUB_REF:-})"
3933
if [[ -z $branch ]]; then
4034
branch="$($GIT describe --all --exact-match --always $commitish 2>/dev/null || echo $commitish)";
41-
fi;
35+
fi
4236

4337
desc="$($GIT describe --tags --long --match='[0-9]*.[0-9]*.[0-9]*' $commitish 2>/dev/null || echo '0.0.0-0')";
44-
current_version="${desc%%-*}";
45-
branch_type="${branch%/*}";
46-
branch_short_name="${branch#*/}";
47-
48-
if [ "$branch_type" = "$current_version" ]; then
49-
branch_type="release";
50-
fi;
38+
current_version="${desc%%-*}"
39+
github_pr_regex="^refs/pull/([0-9]+)/merge"
40+
if [[ $branch =~ $github_pr_regex ]]; then
41+
branch_type="feature"
42+
branch_short_name="pr${BASH_REMATCH[1]}"
43+
else
44+
branch_type="${branch%/*}"
45+
branch_short_name="${branch#*/}"
46+
if [ "$branch_type" = "$current_version" ]; then
47+
branch_type="release"
48+
fi
49+
fi
5150

5251
major="${current_version%%.*}";
5352
minor="${current_version%.*}";

0 commit comments

Comments
 (0)