-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
120 lines (106 loc) · 4.05 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
name: 'Arturo Bundler'
description: 'Bundle Arturo applications as executable binaries'
branding:
icon: package
color: purple
inputs:
token:
description: >-
The GITHUB_TOKEN secret.
required: true
arch:
description: >-
The architecture to build for.
(one of: 'x86', 'arm', 'arm64', 'amd64', 'native')
default: 'native'
entry:
description: >-
Entry file for the executable.
required: true
target:
description: >-
The name of the final binary.
default: 'auto'
version:
description: >-
The version - in case you want to include it in the archive names.
default: ''
release:
description: >-
Prepare for release.
default: 'false'
runs:
using: "composite"
steps:
- name: Install Arturo
uses: arturo-lang/arturo-action@main
with:
token: ${{ inputs.token }}
arch: ${{ inputs.arch }}
- name: Generate executable
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
export PATH="${{ github.workspace }}/nim/nim-2.0.4/bin":$PATH
fi
if [ "${{ inputs.target }}" = "auto" ]; then
arturo --bundle ${{ inputs.entry }}
entry="${{ inputs.entry }}"
xbase=${entry##*/}
xpref=${xbase%.*}
if [ "${{ runner.os }}" != "Windows" ]; then
sudo chmod +x $xpref
fi
echo "EXEFILE=$xpref" >> $GITHUB_ENV
echo "name=$xpref" >> $GITHUB_ENV
else
arturo --bundle --as:${{ inputs.target }} ${{ inputs.entry }}
if [ "${{ runner.os }}" != "Windows" ]; then
sudo chmod +x ${{ inputs.target }}
fi
echo "EXEFILE=${{ inputs.target }}" >> $GITHUB_ENV
echo "name=${{ inputs.target }}" >> $GITHUB_ENV
fi
if [[ "${{ runner.arch }}" = "ARM64" || "${{ inputs.arch }}" = "arm64" ]]; then
echo "ARCHNAME=arm64" >> $GITHUB_ENV
else
echo "ARCHNAME=amd64" >> $GITHUB_ENV
fi
if [ "${{ inputs.version }}" != "" ]; then
echo "VERSION=-${{ inputs.version }}" >> $GITHUB_ENV
echo "version=${{ inputs.version }}" >> $GITHUB_ENV
else
echo "VERSION=" >> $GITHUB_ENV
echo "version=" >> $GITHUB_ENV
fi
if [ "${{ inputs.release }}" = "true" ]; then
if [ "${{ inputs.version }}" = "" ]; then
ARCHV_VERS=$(arturo --evaluate "print replace {${{ github.ref_name }}} {/^v/} {}")
echo "VERSION=-$ARCHV_VERS" >> $GITHUB_ENV
fi
fi
OSNAMELOWER=$(arturo --evaluate "print lower {${{ runner.os }}}")
echo "OSNAME=$OSNAMELOWER" >> $GITHUB_ENV
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
- name: Create artifact
run: |
FILENAME="${{ env.EXEFILE }}${{ env.VERSION }}-${{ env.ARCHNAME }}-${{ env.OSNAME }}"
echo "FILENAME=$FILENAME" >> $GITHUB_ENV
mkdir $FILENAME
if [ "${{ runner.os }}" = "Windows" ]; then
cp ${{ env.EXEFILE }}.exe $FILENAME
else
cp ${{ env.EXEFILE }} $FILENAME
fi
if [ "${{ inputs.release }}" = "true" ]; then
if [ "${{ runner.os }}" = "Windows" ]; then
7z a $FILENAME.zip $FILENAME
else
zip -r $FILENAME.zip $FILENAME
fi
fi
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
- name: Upload Artifact
uses: 'actions/upload-artifact@v4'
with:
name: ${{ env.FILENAME }}
path: ${{ env.FILENAME }}${{ inputs.release == 'true' && '.zip' || '' }}