Skip to content

Commit

Permalink
updated runner workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
clragon committed Oct 8, 2023
1 parent da3216c commit 8384521
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ jobs:
distribution: 'adopt'
java-version: '17'

- name: parse flutter version
run: |
export FLUTTER_VERSION=$(./.github/workflows/get_flutter_version.sh)
echo "FLUTTER_VERSION=$FLUTTER_VERSION" >> $GITHUB_ENV
- name: setup flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true

- name: cache flutter dependencies
Expand Down Expand Up @@ -97,10 +102,15 @@ jobs:
- name: setup actions
uses: actions/checkout@v3

- name: parse flutter version
run: |
export FLUTTER_VERSION=$(./.github/workflows/get_flutter_version.sh)
echo "FLUTTER_VERSION=$FLUTTER_VERSION" >> $GITHUB_ENV
- name: setup flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true

- name: cache flutter dependencies
Expand Down Expand Up @@ -150,10 +160,16 @@ jobs:
ruby-version: '3.0'
bundler-cache: true

- name: parse flutter version
run: |
export FLUTTER_VERSION=$(./.github/workflows/get_flutter_version.sh)
echo "FLUTTER_VERSION=$FLUTTER_VERSION" >> $GITHUB_ENV
- name: setup flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true

- name: setup cider
run: dart pub global activate cider
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/get_flutter_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

# Extract the lower bound flutter version from pubspec.yaml
# This is used to pin the version of the flutter sdk for reproducible builds.
# The version is expected to be somewhere in the pubspec.yaml file, in the
# "environment:" section, under the "flutter:" key.
# The version may be a range or a single version.
FLUTTER_VERSION=""

# Fetch the "environment:" section from pubspec.yaml
environment_keys=$(awk "/^environment:\\r?$/,/^\\r?$/" ./pubspec.yaml)

# Fetch the "flutter:" line from the "environment:" section
grep_result=$(echo "$environment_keys" | grep "^ flutter:")

# Check if we found a valid flutter version
if [ -z "$grep_result" ]; then
echo "No valid 'flutter:' entry found under 'environment:' in pubspec.yaml"
exit 1
fi

# Extract the version string from the line
version_string=$(echo "$grep_result" | awk -F"'" '{print $2}')

# Split by <, >, =, and space to find the version.
# We look for the lower bound, so the first non-empty string is the version.
# This should also work if the version is not a range.
FLUTTER_VERSION=$(echo "$version_string" | awk -F"[<>= ]" '{for(i=1;i<=NF;i++) if($i!="") {print $i; exit}}')

# Return the version
echo $FLUTTER_VERSION

0 comments on commit 8384521

Please sign in to comment.