-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.69 KB
/
release_golang.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
name: Create/update tag
on:
push:
tags:
- "v*.*.*"
jobs:
create-tag:
strategy:
matrix:
api_module: [ common,ledger,lostid,notification,ocr,partition,payment,profile,property,settings,files ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest tags
id: get_tags
run: |
# Get the two most recent tags
TAGS=$(git tag --sort=-creatordate | grep '^go/${{ matrix.api_module }}/v' | head -n 2)
echo $TAGS
TAG_ARRAY=($TAGS)
if [ ${#TAG_ARRAY[@]} -lt 2 ]; then
echo "Not enough tags found"
echo "::set-output name=not_enough_tags::true"
exit 0
fi
echo "latest_tag=${TAG_ARRAY[0]}" >> $GITHUB_ENV
echo "previous_tag=${TAG_ARRAY[1]}" >> $GITHUB_ENV
echo "::set-output name=not_enough_tags::false"
- name: Set output if changes found
if: steps.get_tags.outputs.not_enough_tags == 'false'
id: go_module_changed
run: |
if [[ $(git diff --name-only ${{ env.previous_tag }} ${{ env.latest_tag }} | grep 'go/${{ matrix.api_module }}') ]]; then
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
- uses: rickstaa/action-create-tag@v1
if: steps.get_tags.outputs.not_enough_tags == 'true' || steps.go_module_changed.outputs.changed == 'true'
id: "tag_create"
with:
tag: go/${{ matrix.api_module }}/${{github.ref_name}}
tag_exists_error: false
message: "release module go/${{ matrix.api_module }}/${{github.ref_name}}"