Skip to content

chore: update github actions, #14

chore: update github actions,

chore: update github actions, #14

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
if: steps.cache.outputs.cache-hit == 'true'
- 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: steps.cache.outputs.cache-hit != 'true' || steps.cache.outputs.cache-hit == 'true' && steps.cache.outputs.cache-hit == 'true'
- name: Cache versions
uses: actions/cache@v2

Check failure on line 61 in .github/workflows/ios_distribute.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ios_distribute.yml

Invalid workflow file

You have an error in your yaml syntax on line 61
with:
path: version
key: version-${{ env.PREVIOUS_VERSION }}-${{ env.UPDATED_VERSION }}-${{ runner.os }}