Skip to content

Commit b235910

Browse files
feat: add simple check and release GHA workflows
1 parent adce414 commit b235910

File tree

6 files changed

+278
-2
lines changed

6 files changed

+278
-2
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Setup Tools Action
2+
3+
A composite GitHub Action that automatically sets up development tools based on your `.tool-versions` file.
4+
5+
## Features
6+
7+
**Automatic Detection**: Reads `.tool-versions` and sets up all specified tools
8+
🚀 **Smart Caching**: Enables package manager caching by default
9+
🎯 **Conditional Setup**: Only sets up tools that are actually specified
10+
📤 **Version Outputs**: Provides tool versions as outputs for other steps
11+
12+
## Supported Tools
13+
14+
- **Node.js** (`nodejs`) - with yarn/npm caching
15+
- **Ruby** - with bundler caching
16+
- **Python** - with pip caching
17+
- **Java** - using Zulu distribution
18+
19+
## Usage
20+
21+
### Basic Usage
22+
23+
```yaml
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: ./.github/actions/setup-tools
27+
```
28+
29+
### With Custom Options
30+
31+
```yaml
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: ./.github/actions/setup-tools
35+
with:
36+
cache: false # Disable caching
37+
```
38+
39+
### Using Outputs
40+
41+
```yaml
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Setup tools
45+
id: tools
46+
uses: ./.github/actions/setup-tools
47+
48+
- name: Show versions
49+
run: |
50+
echo "Node.js: ${{ steps.tools.outputs.node-version }}"
51+
echo "Ruby: ${{ steps.tools.outputs.ruby-version }}"
52+
```
53+
54+
## Inputs
55+
56+
| Input | Description | Required | Default |
57+
|-------|-------------|----------|---------|
58+
| `cache` | Enable caching for package managers | `false` | `true` |
59+
60+
## Outputs
61+
62+
| Output | Description |
63+
|--------|-------------|
64+
| `nodejs-version` | Node.js version from .tool-versions |
65+
| `node-version` | Node.js version (alias) |
66+
| `ruby-version` | Ruby version from .tool-versions |
67+
| `python-version` | Python version from .tool-versions |
68+
| `java-version` | Java version from .tool-versions |
69+
70+
## Example .tool-versions
71+
72+
```
73+
ruby 3.4.2
74+
nodejs 23.9.0
75+
python 3.11.5
76+
java 17.0.2
77+
```
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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'

.github/workflows/check.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: check
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup tools from .tool-versions
17+
uses: ./.github/actions/setup-tools
18+
19+
- name: Install dependencies
20+
run: yarn install --frozen-lockfile
21+
22+
- name: Run ESLint
23+
run: yarn lint
24+
25+
test-ios-compilation:
26+
runs-on: macos-14
27+
strategy:
28+
matrix:
29+
example: [side-by-side, recursive]
30+
concurrency:
31+
group: '${{ github.workflow }}-${{ matrix.example }}-${{ github.head_ref || github.ref_name }}'
32+
cancel-in-progress: true
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Setup tools from .tool-versions
38+
uses: ./.github/actions/setup-tools
39+
40+
- name: Setup ccache
41+
uses: hendrikmuhs/ccache-action@v1.2
42+
with:
43+
key: ${{ github.job }}-${{ matrix.example }}
44+
max-size: "2G"
45+
46+
- name: Setup ccache path
47+
run: |
48+
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
49+
50+
- name: Install dependencies
51+
run: yarn install --frozen-lockfile
52+
53+
- name: Install example dependencies
54+
working-directory: packages/examples/${{ matrix.example }}
55+
run: yarn install --frozen-lockfile
56+
57+
- name: Build iOS (Release)
58+
working-directory: packages/examples/${{ matrix.example }}
59+
run: |
60+
export PATH="/usr/local/opt/ccache/libexec:$PATH"
61+
npx react-native build-ios --mode Release
62+
63+
- name: ccache stats
64+
run: ccache -s

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: '${{ github.workflow }}-${{ github.head_ref || github.ref_name }}'
10+
cancel-in-progress: true
11+
12+
jobs:
13+
release:
14+
name: Release
15+
runs-on: macos-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup tools from .tool-versions
20+
uses: ./.github/actions/setup-tools
21+
22+
- run: npm ci
23+
24+
- name: Create Release Pull Request or Publish to npm
25+
id: changesets
26+
uses: changesets/action@v1
27+
with:
28+
publish: npm run release
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/examples/recursive/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ target 'MultInstance-Recursive' do
2929
installer,
3030
config[:reactNativePath],
3131
:mac_catalyst_enabled => false,
32-
# :ccache_enabled => true
32+
:ccache_enabled => true
3333
)
3434
end
3535
end

packages/examples/side-by-side/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ target 'MultiInstancePOC' do
3030
installer,
3131
config[:reactNativePath],
3232
:mac_catalyst_enabled => false,
33-
# :ccache_enabled => true
33+
:ccache_enabled => true
3434
)
3535
end
3636
end

0 commit comments

Comments
 (0)