Skip to content

Commit 528467f

Browse files
committed
feat: create reusable workflow to get the latest three tags and use them in matrix in the other two
1 parent 5dae27f commit 528467f

3 files changed

Lines changed: 38 additions & 28 deletions

File tree

.github/workflows/build-apk-from-latest.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,18 @@ permissions:
1616
jobs:
1717

1818
get_latest_tags:
19+
uses: ./.github/workflows/get-latest-tags.yml
20+
21+
show_tags:
1922
runs-on: ubuntu-latest
20-
outputs:
21-
tags: ${{ steps.tags.outputs.tags }}
23+
needs: get_latest_tags
2224

2325
steps:
2426

25-
- uses: actions/checkout@v5
26-
27-
# Obtains the latest three tags that matches v*.*.*
28-
# Just one major.minor. Latest patch
29-
- name: Get latest tags
30-
id: tags
31-
run: |
32-
TAGS=$(git tag --sort=-creatordate \
33-
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
34-
| awk -F. '
35-
{
36-
key = $1 "." $2
37-
if (!seen[key]++) {
38-
print $0
39-
}
40-
}
41-
' \
42-
| head -n 3 \
43-
| jq -R . | jq -s .)
44-
45-
echo "tags=$TAGS" >> $GITHUB_OUTPUT
46-
4727
- name: Show supported upgrade versions
4828
run: |
4929
echo "Upgrade versions:"
50-
echo '${{ steps.tags.outputs.tags }}'
30+
echo '${{ needs.get_latest_tags.outputs.tags }}'
5131
5232
build_sign_apk:
5333
runs-on: ubuntu-latest
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Get latest tags
2+
on:
3+
workflow_call:
4+
outputs:
5+
tags:
6+
value: ${{ jobs.get_latest.outputs.tags }}
7+
description: "Last three minor version's tags"
8+
9+
jobs:
10+
get_latest:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
tags: ${{ steps.tags.outputs.tags }}
14+
steps:
15+
- uses: actions/checkout@v5
16+
- id: tags
17+
run: |
18+
TAGS=$(git tag --sort=-creatordate \
19+
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
20+
| awk -F. '{ key = $1 "." $2; if (!seen[key]++) print $0 }' \
21+
| head -n 3 \
22+
| jq -R . | jq -s .)
23+
echo "tags=$TAGS" >> $GITHUB_OUTPUT

.github/workflows/update.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ jobs:
1818
build_variant: qaRelease
1919
version: master
2020

21+
get_latest_tags:
22+
runs-on: ubuntu-latest
23+
uses: ./.github/workflows/get-latest-tags.yml
24+
2125
update_test:
2226
name: Update test
2327
runs-on: ubuntu-latest
24-
needs: build_apk
28+
needs: build_apk, get_latest_tags
29+
strategy:
30+
matrix:
31+
tag: ${{ fromJson(needs.get_latest_tags.outputs.tags) }}
2532

2633
env:
2734
BUILD_TOOLS_VERSION: "34.0.0"
@@ -107,15 +114,15 @@ jobs:
107114
uses: dawidd6/action-download-artifact@v11
108115
with:
109116
workflow: build-apk-from-latest.yml
110-
name: owncloudSigned-latest
117+
name: owncloudSigned-${{ matrix.tag }}
111118
workflow_conclusion: success
112119
path: ./src/test/resources
113120

114121
# Rename APKs to standard names expected by tests
115122
- name: Rename artifacts
116123
run: |
117124
ls -al ./src/test/resources
118-
mv ./src/test/resources/owncloudSigned-latest.apk ./src/test/resources/owncloudSigned1.apk
125+
mv ./src/test/resources/owncloudSigned-${{ matrix.tag }}.apk ./src/test/resources/owncloudSigned1.apk
119126
mv ./src/test/resources/owncloudSigned-master.apk ./src/test/resources/owncloudSigned2.apk
120127
ls -al ./src/test/resources
121128

0 commit comments

Comments
 (0)