-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
81 lines (73 loc) · 3.06 KB
/
action.yaml
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Check Version
description: Action to check if a projects's version strings are consistent
inputs:
working-dir:
description: The working directory of the project
required: false
default: "."
helm:
description: The project uses Helm
required: false
default: "false"
node:
description: The project uses Node
required: false
default: "false"
dotnet:
description: The project uses Dot Net
required: false
default: "false"
runs:
using: composite
steps:
- name: Check if the application version needs to be checked and get the version
if: "${{ inputs.node == 'true' || inputs.dotnet == 'true' }}"
run: |
echo "APP_VERSION_FILE=$(cat VERSION)" >> $GITHUB_ENV
working-directory: ${{ inputs.working-dir }}
shell: bash
- name: Generate environment variables for Helm
if: "${{ inputs.helm == 'true' }}"
run: |
echo "HELM_VERSION_FILE=$(cat ./charts/VERSION)" >> $GITHUB_ENV
echo "CHART_FILE=$(yq .version ./charts/Chart.yaml)" >> $GITHUB_ENV
working-directory: ${{ inputs.working-dir }}
shell: bash
- name: Check versions in Chart.yaml
if: ${{ inputs.helm == 'true' }}
run: |
[[ "$HELM_VERSION_FILE" == "$CHART_FILE" ]]
working-directory: ${{ inputs.working-dir }}
shell: bash
- name: Generate environment variables for Node
if: "${{ inputs.node == 'true' }}"
run: |
echo "PACKAGE_FILE=$(sed -e 's/^"//' -e 's/"$//' <<< $(jq .version package.json))" >> $GITHUB_ENV
if [ -f "./package-lock.json" ]; then
echo "PACKAGE_LOCK_FILE=$(sed -e 's/^"//' -e 's/"$//' <<< $(jq .version package-lock.json))" >> $GITHUB_ENV
echo "PACKAGE_LOCK_FILE_PACKAGES=$(sed -e 's/^"//' -e 's/"$//' <<< $(jq ".packages.\"\".version" package-lock.json))" >> $GITHUB_ENV
fi
working-directory: ${{ inputs.working-dir }}
shell: bash
- name: Check versions in package.json and package-lock.json
if: ${{ inputs.node == 'true' }}
run: |
if [ -f "./package-lock.json" ]; then
[[ "$APP_VERSION_FILE" == "$PACKAGE_FILE" && "$PACKAGE_FILE" == "$PACKAGE_LOCK_FILE" && "$PACKAGE_LOCK_FILE" == "$PACKAGE_LOCK_FILE_PACKAGES" ]]
else
[[ "$APP_VERSION_FILE" == "$PACKAGE_FILE" ]]
fi
working-directory: ${{ inputs.working-dir }}
shell: bash
- name: Generate environment variables for Dot Net
if: "${{ inputs.dotnet == 'true' }}"
run: |
echo "ASSEMBLY_VERSION=$(find . -name "AssemblyInfo.cs" -exec cat {} + | grep -oP '(?<=^\[assembly: AssemblyVersion\(")[^"]*')" >> $GITHUB_ENV
echo "ASSEMBLY_FILE_VERSION=$(find . -name "AssemblyInfo.cs" -exec cat {} + | grep -oP '(?<=^\[assembly: AssemblyFileVersion\(")[^"]*')" >> $GITHUB_ENV
working-directory: ${{ inputs.working-dir }}
shell: bash
- name: Check versions in AssemblyInfo.cs
if: ${{ inputs.dotnet == 'true' }}
run: |
[[ "$APP_VERSION_FILE" == "$ASSEMBLY_VERSION" && "$ASSEMBLY_VERSION" == "$ASSEMBLY_FILE_VERSION" ]]
shell: bash