@@ -2,7 +2,7 @@ name: Deploy
2
2
3
3
on :
4
4
push :
5
- branches : [main]
5
+ branches : [main, develop ]
6
6
7
7
permissions :
8
8
contents : write
@@ -17,13 +17,18 @@ jobs:
17
17
18
18
- name : Apply version
19
19
run : |
20
- version=$(git log --pretty=format:%s -n 1 | awk -F' ' '{print $2}')
20
+ rg='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
21
+ commit=$(git log --pretty=format:%s -n 1)
22
+ version=$(echo "$commit" | sed -E 's/^release: ?//; s/v([0-9a-zA-Z.-]+)( #[0-9]+)?/\1/; s/ #[0-9]+//')
23
+
24
+ if [[ $version =~ $rg ]]; then
25
+ is_latest=$([[ -z "${BASH_REMATCH[5]:-}" ]] && echo "yes" || echo "no")
21
26
22
- if [[ "$version" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
23
27
echo "APP_VERSION=$version" >> $GITHUB_ENV
28
+ echo "APP_VERSION_IS_LATEST=$is_latest" >> $GITHUB_ENV
24
29
else
25
- echo "Parsed version: $version"
26
- echo "Commit message: $(git log --pretty=format:%s -n 1) "
30
+ echo "Parsed version: ' $version' "
31
+ echo "Commit message: '$commit' "
27
32
exit 1
28
33
fi
29
34
37
42
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38
43
run : |
39
44
gh release create $APP_VERSION \
40
- --title "$APP_VERSION" \
41
- --notes "Please refer to the [documentation](https://bidaro-open-source.github.io/changelog/)." \
42
- --latest
45
+ --title "$APP_VERSION" \
46
+ --notes "Please refer to the [documentation](https://bidaro-open-source.github.io/changelog/)." \
47
+ $([[ "$APP_VERSION_IS_LATEST" == "yes" ]] && echo " --latest" || echo "--latest=false")
43
48
44
49
release-docker :
45
50
name : Create docker release
@@ -50,13 +55,18 @@ jobs:
50
55
51
56
- name : Apply version
52
57
run : |
53
- version=$(git log --pretty=format:%s -n 1 | awk -F' ' '{print $2}')
58
+ rg='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
59
+ commit=$(git log --pretty=format:%s -n 1)
60
+ version=$(echo "$commit" | sed -E 's/^release: ?//; s/v([0-9a-zA-Z.-]+)( #[0-9]+)?/\1/; s/ #[0-9]+//')
61
+
62
+ if [[ $version =~ $rg ]]; then
63
+ is_latest=$([[ -z "${BASH_REMATCH[5]:-}" ]] && echo "yes" || echo "no")
54
64
55
- if [[ "$version" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
56
65
echo "APP_VERSION=$version" >> $GITHUB_ENV
66
+ echo "APP_VERSION_IS_LATEST=$is_latest" >> $GITHUB_ENV
57
67
else
58
- echo "Parsed version: $version"
59
- echo "Commit message: $(git log --pretty=format:%s -n 1) "
68
+ echo "Parsed version: ' $version' "
69
+ echo "Commit message: '$commit' "
60
70
exit 1
61
71
fi
62
72
78
88
context : .
79
89
push : true
80
90
tags : |
81
- ${{ secrets.DOCKERHUB_USERNAME }}/bidaro-migrator:latest
82
- ${{ secrets.DOCKERHUB_USERNAME }}/bidaro-migrator:${{ env.APP_VERSION }}
91
+ ${{ format('{0}/{1}:{2}', secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_REPOSITORY, env.APP_VERSION) }}
92
+ ${{ env.APP_VERSION_IS_LATEST == 'yes' && format('{0}/{1}:latest', secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_REPOSITORY) || null }}
0 commit comments