-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (53 loc) · 2.14 KB
/
ios_distribute.yml
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
name: Cache Flutter App Version
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Read version from pubspec.yaml
id: read-version
run: |
echo "PREVIOUS_VERSION=$(grep 'version:' pubspec.yaml | awk '{print $2}')" >> $GITHUB_ENV
echo "UPDATED_VERSION=$(cat pubspec.yaml | grep 'version:' | awk '{print $2}')" >> $GITHUB_ENV
- name: Restore version from cache
id: cache
uses: actions/cache@v2
with:
path: version
key: version-${{ env.PREVIOUS_VERSION }}-${{ env.UPDATED_VERSION }}-${{ runner.os }}
- name: Check if version is cached
run: |
if [ -f version/version.txt ]; then
echo "Version is cached: $(cat version/version.txt)"
else
echo "Version is not cached"
fi
- name: Increment updated version if necessary
run: |
if [ -f version/version.txt ]; then
cached_previous_version=$(grep 'previous_version:' version/version.txt | awk '{print $2}')
cached_updated_version=$(grep 'updated_version:' version/version.txt | awk '{print $2}')
if [ "${cached_previous_version}" == "${PREVIOUS_VERSION}" ]; then
IFS='+' read -r -a version_components <<< "${cached_updated_version}"
build_number=${version_components[-1]}
((build_number++))
UPDATED_VERSION="${version_components[0]}+${build_number}"
echo "Updated version incremented to: ${UPDATED_VERSION}"
echo "UPDATED_VERSION=${UPDATED_VERSION}" >> $GITHUB_ENV
fi
fi
- name: Save version to cache
run: |
mkdir -p version
echo "previous_version: ${{ env.PREVIOUS_VERSION }}" > version/version.txt
echo "updated_version: ${{ env.UPDATED_VERSION }}" > version/version.txt
if: always()
# - name: Use cached version
# if: steps.cache.outputs.cache-hit == 'true'
# run: |
# echo "Using cached version: $(cat version/version.txt)"