-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
113 lines (110 loc) · 4.33 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
name: "Setup JuleC environment"
description: "Setup a JuleC development environment in your project."
author: "Panquesito7"
branding:
icon: code
color: gray-dark
inputs:
version:
description: "The version of JuleC that will be downloaded. Use \"latest\" for the latest stable release."
required: true
default: "latest"
directory:
description: "Directory where Jule will be downloaded."
required: true
default: "."
architecture:
description: "The architecture that's going to be used. Valid options are \"arm64\", \"amd64\", and \"i386\"."
required: false
default: "amd64"
add-to-path:
description: "Whether to add JuleC to the PATH or not."
required: false
default: "false"
extra-command:
description: "Extra command that will be executed after JuleC is installed."
required: false
default: ""
runs:
using: "composite"
steps:
- name: Check operating system
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "The action doesn't support building on Windows. Exiting script."
exit 1
fi
- name: Install Homebrew if Needed
shell: bash
run: |
if [[ ${{ inputs.version }} == "latest" ]] || [[ ${{ inputs.version }} == "current" ]]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo 'export PATH="/usr/local/bin:$PATH"' >> $GITHUB_PATH
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "export PATH=\$PATH:/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
fi
fi
- name: Install dependencies
shell: bash
run: |
if [[ ${{ inputs.version }} == "latest" ]] || [[ ${{ inputs.version }} == "current" ]]; then
brew update
brew install jq
fi
- name: Adjust directory
shell: bash
run: |
directory="${{ inputs.directory }}"
if [[ ${{ inputs.directory }} == */ ]]; then
directory="${directory%?}"
${{ inputs.directory }}=directory
fi
- name: Clone JuleC
shell: bash
run: |
if [[ ${{ inputs.version }} == "latest" ]] || [[ ${{ inputs.version }} == "current" ]]; then
RELEASES=$(curl -s https://api.github.com/repos/julelang/jule/releases)
LATEST_RELEASE=$(echo "$RELEASES" | jq -r '.[] | select(.draft == false) | .tarball_url' | head -n 1)
curl -o julec.tar.gz $LATEST_RELEASE
mkdir -p ${{ inputs.directory }}/julec-latest
tar -xzf julec.tar.gz -C ${{ inputs.directory }}/julec-latest
elif [[ ${{ inputs.version }} == "dev" ]]; then
git clone https://github.com/julelang/jule.git ${{ inputs.directory }}/julec-${{ inputs.version }}
else
curl -o julec.tar.gz https://github.com/julelang/jule/archive/refs/tags/jule-${{ inputs.version }}.tar.gz -O julec.tar.gz
mkdir -p ${{ inputs.directory }}/julec-${{ inputs.version }}
tar -xzf julec.tar.gz -C ${{ inputs.directory }}/julec-${{ inputs.version }}
fi
- name: Get JuleC IR
shell: bash
run: |
cd ${{ inputs.directory }}/julec-${{ inputs.version }}
architecture=${{ inputs.architecture }}
if [[ "$OSTYPE" == "darwin"* ]] && [[ "$architecture" == "i386" ]]; then
architecture="amd64"
fi
curl -o ir.cpp https://raw.githubusercontent.com/julelang/julec-ir/main/src/$( [[ "$OSTYPE" == "darwin"* ]] && echo darwin || echo linux)-${architecture}.cpp
- name: Compile JuleC
shell: bash
run: |
cd ${{ inputs.directory }}/julec-${{ inputs.version }}
mkdir bin
clang++ -O0 --std=c++17 -Wno-everything -o bin/julec ir.cpp
- name: Add JuleC to the PATH
shell: bash
run: |
if [[ ${{ inputs.add-to-path }} == true ]]; then
echo "export PATH=\$PATH:${{ inputs.directory }}/julec-${{ inputs.version }}/bin/" >> $GITHUB_PATH
fi
- name: Run extra commands
shell: bash
run: |
if [[ -n "${{ inputs.extra-command }}" ]]; then
if [[ ${{ inputs.add-to-path }} == true ]]; then
julec ${{ inputs.extra-command }}
else
${{ inputs.directory }}/julec-${{ inputs.version }}/bin/julec ${{ inputs.extra-command }}
fi
fi