-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
148 lines (147 loc) · 5.72 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
name: 'Install ESMF'
author: 'ESMF'
description: 'Install/Cache ESMF on Runner'
inputs:
build-key:
description: 'Unique Build Key'
required: false
default: ''
version:
description: 'ESMF Version'
required: false
default: 'latest'
esmpy:
description: 'Enable esmpy'
required: false
default: false
rebuild-check:
description: 'Installation Check'
required: false
default: 'standard'
cache:
description: 'Enable Caching'
required: false
default: true
outputs:
esmf-cache-key:
description: "ESMF Cache Key"
value: ${{steps.rebuild-check-esmf.outputs.esmf-cache-key}}
runs:
using: "composite"
steps:
- id: version-esmf
shell: bash
run: |
if [[ "${{inputs.version}}" == "latest" ]]; then
ESMF_API_URL="https://api.github.com/repos/esmf-org/esmf/releases/latest"
curl --silent -L "${ESMF_API_URL}" > ${{runner.temp}}/.esmf-gh.info
ESMF_VERSION=`cat ${{runner.temp}}/.esmf-gh.info | grep '^ "tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'`
rm -f ${{runner.temp}}/.esmf-gh.info
ESMF_URL="https://github.com/esmf-org/esmf/archive/refs/tags/${ESMF_VERSION}.tar.gz"
elif [[ "${{inputs.version}}" == "develop" ]]; then
ESMF_API_URL="https://api.github.com/repos/esmf-org/esmf/branches/develop?page=1"
curl --silent -L "${ESMF_API_URL}" > ${{runner.temp}}/.esmf-gh.info
ESMF_COMMIT=`cat ${{runner.temp}}/.esmf-gh.info | grep '^ "sha":' | sed -E 's/.*"([^"]+)".*/\1/'`
rm -f ${{runner.temp}}/.esmf-gh.info
ESMF_URL="https://github.com/esmf-org/esmf/archive/${ESMF_COMMIT}.tar.gz"
ESMF_VERSION="develop"
echo "ESMF_COMMIT=${ESMF_COMMIT}" >> ${GITHUB_ENV}
else
ESMF_URL="https://github.com/esmf-org/esmf/archive/refs/tags/${{inputs.version}}.tar.gz"
ESMF_VERSION="${{inputs.version}}"
fi
echo "esmf-url=${ESMF_URL}" >> ${GITHUB_OUTPUT}
echo "ESMF_VERSION=${ESMF_VERSION}" >> ${GITHUB_ENV}
if [ -z "${{env.ESMF_INSTALL_PREFIX}}" ]; then
echo "ESMF_ROOT=${HOME}/.esmf-cache" >> ${GITHUB_ENV}
else
echo "ESMF_ROOT=${{env.ESMF_INSTALL_PREFIX}}" >> ${GITHUB_ENV}
fi
- id: cache-key-esmf
shell: bash
env:
ESMF_DIR: ${{runner.temp}}/esmf-src
run: |
mkdir -p ${ESMF_DIR}
cd ${ESMF_DIR}
if [[ "${{inputs.rebuild-check}}" == "quick" ]]; then
printenv | grep "^ESMF_" > ${{github.workspace}}/.esmf-cache.txt
echo "RUNNER_OS=${{runner.os}}" >> ${{github.workspace}}/.esmf-cache.txt
echo "RUNNER_ARCH=${{runner.arch}}" >> ${{github.workspace}}/.esmf-cache.txt
else
curl --silent -L ${{steps.version-esmf.outputs.esmf-url}} | tar --strip-components=1 -xz
if [[ "${{inputs.rebuild-check}}" == "thorough" ]]; then
make info | sed -E '/Compiling on|Machine characteristics/d' > ${{github.workspace}}/.esmf-cache.txt
else
make info | sed -E '/Compiling on|Machine characteristics/d' | sed '/Make version:/{N;d;}' > ${{github.workspace}}/.esmf-cache.txt
fi
fi
if [ ! -z "${{inputs.build-key}}" ]; then
echo "ESMF_BUILD_KEY=${{inputs.build-key}}" >> ${{github.workspace}}/.esmf-cache.txt
fi
- id: cache-esmf
if: inputs.cache == 'true'
uses: actions/cache@v4
with:
path: ${{env.ESMF_ROOT}}
key: esmf@${{env.ESMF_VERSION}}-${{hashFiles('.esmf-cache.txt')}}
- id: environment-esmf
shell: bash
run: |
echo "ESMFMKFILE=${{env.ESMF_ROOT}}/lib/esmf.mk" >> $GITHUB_ENV
LD_LIBRARY_PATH=${{env.ESMF_ROOT}}/lib:${LD_LIBRARY_PATH}
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
echo "${{env.ESMF_ROOT}}/bin" >> $GITHUB_PATH
- id: rebuild-check-esmf
shell: bash
env:
ESMF_CACHE_KEY: "${{hashFiles('.esmf-cache.txt')}}"
run: |
if [ -f "$ESMFMKFILE" ]; then
INSTALLED_CACHE_KEY=`cat $ESMFMKFILE | grep -m1 'ESMF_CACHE_KEY\='` || true
INSTALLED_CACHE_KEY=${INSTALLED_CACHE_KEY#*=}
if [ "$INSTALLED_CACHE_KEY" == "$ESMF_CACHE_KEY" ]; then
echo "key-match=true" >> ${GITHUB_OUTPUT}
else
echo "key-match=false" >> ${GITHUB_OUTPUT}
fi
else
echo "key-match=false" >> ${GITHUB_OUTPUT}
fi
echo "esmf-cache-key=$ESMF_CACHE_KEY" >> $GITHUB_OUTPUT
rm -f ${{github.workspace}}/.esmf-cache.txt
- id: install-esmf
if: steps.rebuild-check-esmf.outputs.key-match != 'true'
shell: bash
env:
ESMF_DIR: ${{runner.temp}}/esmf-src
ESMF_INSTALL_MODDIR: "mod"
ESMF_INSTALL_BINDIR: "bin"
ESMF_INSTALL_LIBDIR: "lib"
ESMF_INSTALL_DOCDIR: "doc"
ESMF_INSTALL_HEADERDIR: "include"
ESMF_INSTALL_PREFIX: "${{env.ESMF_ROOT}}"
ESMF_CACHE_KEY: "${{steps.rebuild-check-esmf.outputs.esmf-cache-key}}"
run: |
cd ${ESMF_DIR}
if [[ "${{inputs.rebuild-check}}" == "quick" ]]; then
curl --silent -L ${{steps.version-esmf.outputs.esmf-url}} | tar --strip-components=1 -xz
fi
make -j 2
make install
mkdir -p ${ESMF_INSTALL_PREFIX}/addon/esmpy
if [ -d "src/addon/esmpy" ]; then
rsync -a src/addon/esmpy/ ${ESMF_INSTALL_PREFIX}/addon/esmpy
elif [ -d "src/addon/ESMPy" ]; then
rsync -a src/addon/ESMPy/ ${ESMF_INSTALL_PREFIX}/addon/esmpy
fi
- id: install-esmpy
if: inputs.esmpy == 'true'
shell: bash
run: |
cd ${{env.ESMF_ROOT}}/addon/esmpy
python -m pip install --upgrade pip
python -m pip install .
branding:
icon: download
color: blue