-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
123 lines (105 loc) · 3.6 KB
/
action.yml
File metadata and controls
123 lines (105 loc) · 3.6 KB
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
name: 'Setup STruC++'
description: 'Download and configure STruC++ (IEC 61131-3 Structured Text to C++ compiler)'
branding:
icon: 'cpu'
color: 'blue'
inputs:
version:
description: 'STruC++ version to install (e.g., "0.1.4"). Default: latest release.'
required: false
default: 'latest'
token:
description: 'GitHub token for downloading releases.'
required: false
default: ${{ github.token }}
outputs:
version:
description: 'Installed STruC++ version'
value: ${{ steps.version.outputs.version }}
path:
description: 'Path to STruC++ installation directory'
value: ${{ steps.setup.outputs.path }}
runs:
using: 'composite'
steps:
- name: Determine version
id: version
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
if [ "${{ inputs.version }}" = "latest" ]; then
VERSION=$(gh release view --repo Autonomy-Logic/STruCpp --json tagName -q '.tagName' | sed 's/^v//')
else
VERSION="${{ inputs.version }}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Installing STruC++ v${VERSION}"
- name: Determine platform asset
id: platform
shell: bash
run: |
OS="${{ runner.os }}"
ARCH="${{ runner.arch }}"
case "${OS}-${ARCH}" in
Linux-X64) ASSET="strucpp-linux-x64.tar.gz" ;;
Linux-ARM64) ASSET="strucpp-linux-arm64.tar.gz" ;;
macOS-X64) ASSET="strucpp-darwin-x64.zip" ;;
macOS-ARM64) ASSET="strucpp-darwin-arm64.zip" ;;
Windows-X64) ASSET="strucpp-win32-x64.zip" ;;
Windows-ARM64) ASSET="strucpp-win32-arm64.zip" ;;
*) echo "::error::Unsupported platform: ${OS}-${ARCH}" && exit 1 ;;
esac
echo "asset=$ASSET" >> "$GITHUB_OUTPUT"
- name: Cache STruC++
id: cache
uses: actions/cache@v4
with:
path: ~/.strucpp
key: strucpp-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
- name: Download and install
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
ASSET="${{ steps.platform.outputs.asset }}"
INSTALL_DIR="$HOME/.strucpp"
mkdir -p "$INSTALL_DIR" /tmp/strucpp-dl
echo "Downloading STruC++ v${VERSION} (${ASSET})..."
gh release download "v${VERSION}" \
--repo Autonomy-Logic/STruCpp \
--pattern "$ASSET" \
--dir /tmp/strucpp-dl
# Extract based on archive type
cd /tmp/strucpp-dl
if [[ "$ASSET" == *.tar.gz ]]; then
tar xzf "$ASSET"
else
unzip -q "$ASSET"
fi
# Move contents from strucpp/ subdirectory to install dir
cp -r strucpp/* "$INSTALL_DIR/"
# Ensure binary is executable
if [ -f "$INSTALL_DIR/strucpp" ]; then
chmod +x "$INSTALL_DIR/strucpp"
fi
# Cleanup
rm -rf /tmp/strucpp-dl
- name: Add to PATH and verify
id: setup
shell: bash
run: |
INSTALL_DIR="$HOME/.strucpp"
# Convert to native path on Windows so PowerShell can resolve it
if [[ "${{ runner.os }}" == "Windows" ]]; then
NATIVE_PATH="$(cygpath -w "$INSTALL_DIR")"
else
NATIVE_PATH="$INSTALL_DIR"
fi
echo "$NATIVE_PATH" >> "$GITHUB_PATH"
echo "path=$NATIVE_PATH" >> "$GITHUB_OUTPUT"
# Verify installation
"$INSTALL_DIR/strucpp" --version
echo "STruC++ v${{ steps.version.outputs.version }} ready"