Skip to content

Commit 799318a

Browse files
ErBWsbartekpacia
andauthored
feat: add git source support (#334)
* try to add git source support * improve GIT_SOURCE output name * fix syntax --------- Co-authored-by: Bartek Pacia <[email protected]>
1 parent 8535a80 commit 799318a

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.github/workflows/workflow.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ jobs:
2727
strategy:
2828
matrix:
2929
operating-system:
30-
[ubuntu-latest, windows-latest, macos-latest, macos-13]
30+
- ubuntu-latest
31+
- windows-latest
32+
- macos-latest
33+
- macos-13
3134
channel: [stable, beta, master]
3235
dry-run: [true, false]
36+
git-source:
37+
- https://github.com/flutter/flutter.git
38+
- https://github.com/Flutter-Foundation/flutter.git
39+
- https://gitee.com/harmonycommando_flutter/flutter.git
3340
include:
3441
- operating-system: ubuntu-latest
3542
channel: main
@@ -42,6 +49,7 @@ jobs:
4249
with:
4350
channel: ${{ matrix.channel }}
4451
dry-run: ${{ matrix.dry-run }}
52+
git-source: ${{ matrix.git-source }}
4553
- name: Echo outputs
4654
run: |
4755
echo RUNNER-OS=${{ runner.os }}

action.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ inputs:
4646
description: If true, get outputs but do not install Flutter
4747
required: false
4848
default: "false"
49+
git-source:
50+
description: Git clone source
51+
required: false
52+
default: "https://github.com/flutter/flutter.git"
4953

5054
outputs:
5155
CHANNEL:
@@ -69,6 +73,9 @@ outputs:
6973
PUB-CACHE-PATH:
7074
value: "${{ steps.flutter-action.outputs.PUB-CACHE-PATH }}"
7175
description: Path to pub cache
76+
GIT_SOURCE:
77+
value: "${{ steps.flutter-action.outputs.GIT_SOURCE }}"
78+
description: Git source of Flutter SDK repository to clone
7279

7380
runs:
7481
using: composite
@@ -97,6 +104,7 @@ runs:
97104
-c '${{ inputs.cache-path }}' \
98105
-l '${{ inputs.pub-cache-key }}' \
99106
-d '${{ inputs.pub-cache-path }}' \
107+
-g '${{ inputs.git-source }}' \
100108
${{ inputs.channel }}
101109
102110
- name: Cache Flutter

setup.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ TEST_MODE=false
7878
ARCH=""
7979
VERSION=""
8080
VERSION_FILE=""
81+
GIT_SOURCE=""
8182

82-
while getopts 'tc:k:d:l:pa:n:f:' flag; do
83+
while getopts 'tc:k:d:l:pa:n:f:g:' flag; do
8384
case "$flag" in
8485
c) CACHE_PATH="$OPTARG" ;;
8586
k) CACHE_KEY="$OPTARG" ;;
@@ -96,6 +97,7 @@ while getopts 'tc:k:d:l:pa:n:f:' flag; do
9697
exit 1
9798
fi
9899
;;
100+
g) GIT_SOURCE="$OPTARG" ;;
99101
?) exit 2 ;;
100102
esac
101103
done
@@ -121,6 +123,7 @@ CHANNEL="${ARR_CHANNEL[0]:-}"
121123
[ -z "$CACHE_KEY" ] && CACHE_KEY="flutter-:os:-:channel:-:version:-:arch:-:hash:"
122124
[ -z "$PUB_CACHE_KEY" ] && PUB_CACHE_KEY="flutter-pub-:os:-:channel:-:version:-:arch:-:hash:"
123125
[ -z "$PUB_CACHE_PATH" ] && PUB_CACHE_PATH="default"
126+
[ -z "$GIT_SOURCE" ] && GIT_SOURCE="https://github.com/flutter/flutter.git"
124127

125128
# `PUB_CACHE` is what Dart and Flutter looks for in the environment, while
126129
# `PUB_CACHE_PATH` is passed in from the action.
@@ -213,7 +216,7 @@ fi
213216

214217
if [ ! -x "$CACHE_PATH/bin/flutter" ]; then
215218
if [ "$CHANNEL" = "master" ] || [ "$CHANNEL" = "main" ]; then
216-
git clone -b "$CHANNEL" https://github.com/flutter/flutter.git "$CACHE_PATH"
219+
git clone -b "$CHANNEL" "$GIT_SOURCE" "$CACHE_PATH"
217220
if [ "$VERSION" != "any" ]; then
218221
git config --global --add safe.directory "$CACHE_PATH"
219222
(cd "$CACHE_PATH" && git checkout "$VERSION")

0 commit comments

Comments
 (0)