1
+ name : ' Setup Tools from .tool-versions'
2
+ description : ' Automatically setup tools (Node.js, Ruby, etc.) based on .tool-versions file'
3
+ author : ' react-native-multinstance'
4
+
5
+ inputs :
6
+ cache :
7
+ description : ' Enable caching for package managers'
8
+ required : false
9
+ default : ' true'
10
+
11
+ outputs :
12
+ nodejs-version :
13
+ description : ' Node.js version from .tool-versions'
14
+ value : ${{ steps.read-versions.outputs.nodejs-version }}
15
+ node-version :
16
+ description : ' Node.js version (alias)'
17
+ value : ${{ steps.read-versions.outputs.node-version }}
18
+ ruby-version :
19
+ description : ' Ruby version from .tool-versions'
20
+ value : ${{ steps.read-versions.outputs.ruby-version }}
21
+ python-version :
22
+ description : ' Python version from .tool-versions'
23
+ value : ${{ steps.read-versions.outputs.python-version }}
24
+ java-version :
25
+ description : ' Java version from .tool-versions'
26
+ value : ${{ steps.read-versions.outputs.java-version }}
27
+
28
+ runs :
29
+ using : ' composite'
30
+ steps :
31
+ - name : Read .tool-versions
32
+ id : read-versions
33
+ shell : bash
34
+ run : |
35
+ if [[ ! -f ".tool-versions" ]]; then
36
+ echo "❌ .tool-versions not found"
37
+ exit 1
38
+ fi
39
+
40
+ echo "📖 Reading tool versions from .tool-versions"
41
+
42
+ # Read each line from .tool-versions
43
+ while IFS= read -r line || [[ -n "$line" ]]; do
44
+ # Skip empty lines and comments
45
+ if [[ -z "$line" ]] || [[ "$line" =~ ^[[:space:]]*# ]]; then
46
+ continue
47
+ fi
48
+
49
+ # Parse tool name and version
50
+ if [[ "$line" =~ ^([^[:space:]]+)[[:space:]]+(.+)$ ]]; then
51
+ tool_name="${BASH_REMATCH[1]}"
52
+ tool_version="${BASH_REMATCH[2]}"
53
+
54
+ # Set outputs with original names
55
+ echo "${tool_name}-version=${tool_version}" >> "$GITHUB_OUTPUT"
56
+
57
+ # Common aliases for popular tools
58
+ case "$tool_name" in
59
+ "nodejs")
60
+ echo "node-version=${tool_version}" >> "$GITHUB_OUTPUT"
61
+ ;;
62
+ "python")
63
+ echo "py-version=${tool_version}" >> "$GITHUB_OUTPUT"
64
+ ;;
65
+ "java")
66
+ echo "jdk-version=${tool_version}" >> "$GITHUB_OUTPUT"
67
+ ;;
68
+ esac
69
+
70
+ echo "✅ Found ${tool_name}: ${tool_version}"
71
+ fi
72
+ done < ".tool-versions"
73
+
74
+ - name : Setup Node.js
75
+ if : steps.read-versions.outputs.nodejs-version
76
+ uses : actions/setup-node@v4
77
+ with :
78
+ node-version : ${{ steps.read-versions.outputs.nodejs-version }}
79
+ cache : ${{ inputs.cache == 'true' && 'yarn' || '' }}
80
+
81
+ - name : Setup Ruby
82
+ if : steps.read-versions.outputs.ruby-version
83
+ uses : ruby/setup-ruby@v1
84
+ with :
85
+ ruby-version : ${{ steps.read-versions.outputs.ruby-version }}
86
+ bundler-cache : ${{ inputs.cache }}
87
+
88
+ - name : Setup Python
89
+ if : steps.read-versions.outputs.python-version
90
+ uses : actions/setup-python@v5
91
+ with :
92
+ python-version : ${{ steps.read-versions.outputs.python-version }}
93
+ cache : ${{ inputs.cache == 'true' && 'pip' || '' }}
94
+
95
+ - name : Setup Java
96
+ if : steps.read-versions.outputs.java-version
97
+ uses : actions/setup-java@v4
98
+ with :
99
+ distribution : ' zulu'
100
+ java-version : ${{ steps.read-versions.outputs.java-version }}
101
+
102
+ branding :
103
+ icon : ' settings'
104
+ color : ' blue'
0 commit comments