-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (97 loc) · 3.33 KB
/
Copy pathcheck-release.yml
File metadata and controls
101 lines (97 loc) · 3.33 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
on:
workflow_call:
inputs:
head-ref:
description: "The head ref of the pull request."
type: string
required: true
base-ref:
description: "The base ref of the pull request."
type: string
required: true
event-name:
description: "The name of the event that triggered the workflow."
type: string
required: true
jobs:
check-release:
name: Check Release
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: VirdocsSoftware/github-actions/.github/actions/predict-next-version@main
id: predict-next-version
- name: Debug Outputs
run: |
echo "DEBUG: Steps outputs"
echo "Latest Version: ${{ steps.predict-next-version.outputs.latest-version }}"
echo "Next Version: ${{ steps.predict-next-version.outputs.next-version }}"
echo "Latest Version: ${{ env.LATEST_VERSION }}"
echo "Next Version: ${{ env.NEXT_VERSION }}"
- name: Install Dependencies
run: |
sudo apt install figlet
- name: Confirm Release Version
run: |
echo "${{ toJson(steps.predict-next-version.outputs) }}"
if [ "$EVENT" != "pull_request" ]; then
echo "Not applicable"
exit 0
fi
if [ "$PACKAGE_PATH" == "" ]; then
PACKAGE_PATH=.
fi
if [ "$SCRIPT_PATH" == "" ]; then
SCRIPT_PATH=$(dirname $BASH_SOURCE)
fi
if [ "$JQ_PATH" == "" ]; then
JQ_PATH=$(which jq)
if [ -z "$JQ_PATH" ]; then
echo "jq is not installed"
exit 1
fi
fi
if [ "$GIT_PATH" == "" ]; then
GIT_PATH=$(which git)
if [ -z "$GIT_PATH" ]; then
echo "git is not installed"
exit 1
fi
fi
if [ "$FIGLET_PATH" == "" ]; then
FIGLET_PATH=$(which figlet)
if [ -z "$FIGLET_PATH" ]; then
echo "figlet is not installed"
exit 1
fi
fi
# get branch info
CURRENT_BRANCH=$($GIT_PATH rev-parse --abbrev-ref HEAD);
PARSED_BRANCH_VERSION=$(echo $CURRENT_BRANCH | sed -E 's/(release|hotfix)\/v//')
if [ "$TARGET_BRANCH" == "" ]; then
echo "Target branch is not specified in TARGET_BRANCH environment variable"
exit 1
fi
if [ "$TARGET_BRANCH" != "main" ]; then
echo "Nothing to do here"
exit 0
fi
PACKAGE_VERSION=$($JQ_PATH -r .version $PACKAGE_PATH/package.json);
if [ "$NEXT_PREDICTED_RELEASE" != "$PACKAGE_VERSION" ]; then
echo "Release Version = $NEXT_PREDICTED_RELEASE";
echo "Package Version = $PACKAGE_VERSION";
echo "
See: https://virdocs.atlassian.net/wiki/x/LADQo"
exit 1
else
echo "Everything is good. Ready to release"
$FIGLET_PATH "version $PACKAGE_VERSION"
fi
env:
CURRENT_BRANCH: ${{ inputs.head-ref }}
TARGET_BRANCH: ${{ inputs.base-ref }}
EVENT: ${{ inputs.event-name }}
NEXT_PREDICTED_RELEASE: ${{ env.NEXT_VERSION }}