-
Notifications
You must be signed in to change notification settings - Fork 5
45 lines (38 loc) · 1.61 KB
/
pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Compare versions on Pull Request
on:
pull_request:
branches:
- master
jobs:
compare-version:
name: Compare versions in current branch and master
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get source version
id: source-version
run: |
echo "Source branch: ${{ github.head_ref }}"
version=$(cat ./src/Dodo.HttpClient.ResiliencePolicies/Dodo.HttpClient.ResiliencePolicies.csproj | grep "<VersionPrefix>" | sed -e "s/ *<\/*VersionPrefix>//g")
echo "Source version: $version"
if [ -z "${version// }" ]; then exit 1; fi
echo "::set-output name=version::$version"
- uses: actions/checkout@v2
with:
ref: master
- name: Get target version
id: target-version
run: |
echo "Target branch: ${{ github.base_ref }}"
version=$(cat ./src/Dodo.HttpClient.ResiliencePolicies/Dodo.HttpClient.ResiliencePolicies.csproj | grep "<VersionPrefix>" | sed -e "s/ *<\/*VersionPrefix>//g")
echo "Target version: $version"
if [ -z "${version// }" ]; then exit 1; fi
echo "::set-output name=version::$version"
- name: Compare versions
run: |
versions=(${{ env.source_version }} ${{ env.target_version }})
IFS=$'\n' sorted_versions=($(sort -V <<<"${versions[*]}")); unset IFS
if [ $sorted_versions == ${{ env.source_version }} ]; then exit 1; fi
env:
source_version: ${{ steps.source-version.outputs.version }}
target_version: ${{ steps.target-version.outputs.version }}