-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
173 lines (148 loc) · 5.65 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: 'Build Ring Project'
description: 'A GitHub Action that compiles Ring Programming Language projects.'
author: 'ysdragon'
inputs:
file:
description: 'Path to the Ring source file to build'
required: true
output_exe:
description: 'Set to `true` to generate an executable using Ring2EXE'
required: false
default: 'false'
args:
description: 'Additional arguments to pass to Ring or Ring2EXE'
required: false
default: ''
ring_packages:
description: 'Space-separated list of packages to install from RingPM'
required: false
version:
description: 'Specify the version of the Ring compiler to use (commit ID, tag, branch, or hash)'
required: false
default: 'v1.22'
branding:
color: 'blue'
icon: 'package'
runs:
using: 'composite'
steps:
- name: Set up environment variables
shell: bash
run: |
echo "RING_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
echo "RING_FILE=${{ inputs.file }}" >> $GITHUB_ENV
echo "RING_ARGS=${{ inputs.args }}" >> $GITHUB_ENV
- name: Install 7zip (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install 7zip -y
- name: Set up Ring (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Create temp directory
Write-Host "Creating temporary directory..."
$downloadDir = "C:\RingTemp"
New-Item -ItemType Directory -Force -Path $downloadDir
cd $downloadDir
# Download Ring installer
$version = "${{ inputs.version }}"
$cleanVersion = $version -replace '^v', ''
$installerUrl = "https://github.com/ring-lang/ring/releases/download/$version/Ring_${cleanVersion}_Windows_64bit.exe"
Write-Host "Downloading Ring from: $installerUrl"
try {
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $installerUrl -OutFile "ring_installer.exe" -UseBasicParsing
# Extract quietly
Write-Host "Extracting Ring installer..."
& 7z x "ring_installer.exe" -o"C:\" -y -bso0 -bsp0
# Add Ring to PATH
Write-Host "Adding Ring to PATH..."
echo "C:\ring\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Test Ring installation
$env:Path = "C:\ring\bin;" + $env:Path
Write-Host "Testing Ring installation..."
# Install packages if specified
if ("${{ inputs.ring_packages }}" -ne "") {
Write-Host "Installing specified packages..."
$packages = "${{ inputs.ring_packages }}".Split(" ")
foreach ($package in $packages) {
Write-Host "Installing package: $package"
& "C:\ring\bin\ringpm" install $package
}
}
Write-Host "Ring setup completed successfully"
} catch {
Write-Host "Error during Ring setup: $_"
Write-Host "Stack trace: $($_.ScriptStackTrace)"
exit 1
}
- name: Set up Ring (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
set -x
# Clone Ring repository
git clone --depth 1 --branch ${{ inputs.version }} -q https://github.com/ring-lang/ring $HOME/ring
cd $HOME/ring
# Install dependencies
cd build
chmod +x installdepmac.sh
./installdepmac.sh > /dev/null 2>&1
# Build Ring
chmod +x buildclang.sh
./buildclang.sh > /dev/null 2>&1
# Debug
ls $HOME/ring/lib/
# Add Ring to PATH
echo "$HOME/ring/bin" >> $GITHUB_PATH
export PATH="$HOME/ring/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/ring/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="$HOME/ring/lib:$DYLD_LIBRARY_PATH"
# Install packages if specified
if [ ! -z "${{ inputs.ring_packages }}" ]; then
echo "Installing specified packages..."
for package in ${{ inputs.ring_packages }}; do
echo "Installing package: ${package}"
ringpm install "${package}"
done
fi
echo "Ring setup completed successfully"
- name: Set up Ring (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
# Use the existing Docker container for Linux
docker pull quay.io/ydrag0n/ring:latest
- name: Build project (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
if ("${{ inputs.output_exe }}" -eq "true") {
ring2exe ${{ inputs.args }} ${{ inputs.file }}
} else {
$output = ring ${{ inputs.args }} ${{ inputs.file }}
Write-Output $output
if ($output -match "Error") {
exit 1
}
}
- name: Build project (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
if [ "${{ inputs.output_exe }}" = "true" ]; then
ring2exe ${{ inputs.args }} ${{ inputs.file }}
else
output=$(ring ${{ inputs.args }} ${{ inputs.file }})
echo "$output"
if [[ "$output" == *"Error"* ]]; then
exit 1
fi
fi
- name: Build project (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
docker run --rm -v "$(pwd):/app" -e INPUT_VERSION="${{ inputs.version }}" -e INPUT_ARGS="${{ inputs.args }}" -e INPUT_RING_PACKAGES="${{ inputs.ring_packages }}" -e INPUT_OUTPUT_EXE="${{ inputs.output_exe }}" -e INPUT_FILE="${{ inputs.file }}" quay.io/ydrag0n/ring:latest