-
Notifications
You must be signed in to change notification settings - Fork 27
176 lines (157 loc) · 6.35 KB
/
OnPush.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
174
175
176
name: On Push
on:
workflow_dispatch:
push:
branches: [ "devel", "main" ]
# branches: [ "*" ]
jobs:
check:
permissions:
actions: read
contents: read
security-events: write
environment: Publish
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-latest]
# os: [ubuntu-22.04]
# The name of the operating system for performing single O/S actions
env:
MAIN_OS: ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
# The version identifier is the first word in CHANGE_LOG and must have 4 or 3 components on the
# "devel" and "main" branches respectively. Additionally, the second word in CHANGE_LOG must be
# a valid timestamp for a push to the "main" branch.
- name: Vet CHANGE_LOG
if: matrix.os == env.MAIN_OS
run: |
versionId=`awk '{print $1;exit}' CHANGE_LOG`
if test ${{ github.ref_name }} = devel; then
echo $versionId | egrep '^[0-9]+(\.[0-9]+){3}$' >/dev/null || exit 1
elif test ${{ github.ref_name }} = main; then
echo $versionId | egrep '^[0-9]+(\.[0-9]+){2}$' >/dev/null || exit 1
awk '{print $2;exit}' CHANGE_LOG |
egrep '^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3])(:[0-5][0-9]){2}[-+]((0[0-9]|1[0-3])([0-5][0-9]))$' \
>/dev/null || exit 1
fi
# File "configure.ac" must have the same version identifier as CHANGE_LOG
- name: Vet configure.ac
if: matrix.os == env.MAIN_OS
run: |
versionId=`awk '{print $1;exit}' CHANGE_LOG`
egrep "^AC_INIT.*\[$versionId\]" configure.ac >/dev/null || exit 1
# Gnu autotools require an "m4" subdirectory
- run: mkdir m4
- name: Provision Ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get install doxygen
autoreconf -fi
- name: Provision MacOS
if: matrix.os == 'macos-latest'
run: |
brew install [email protected]
brew install automake
brew install doxygen
/usr/local/opt/[email protected]/bin/autoreconf -fi
# Coverity Scan is better
# - name: Initialize CodeQL
# if: matrix.os == env.MAIN_OS && github.ref_name == 'devel'
# uses: github/codeql-action/init@v2
# with:
# languages: "cpp"
- name: Make Source Distribution
run: |
./configure --prefix=/tmp/ldm --with-noaaport --with-gribinsert \
|| { cat configure; exit 1; }
make all
if test "${{ github.ref_name }}" = "main"; then
make dist
else
make distcheck
fi
# - name: Perform CodeQL Analysis
# if: matrix.os == env.MAIN_OS && github.ref_name == 'devel'
# uses: github/codeql-action/analyze@v2
# with:
# category: "cpp"
- name: Publish Source Distribution and Documentation
if: matrix.os == env.MAIN_OS && github.ref_name == 'main'
env:
USER: ${{ secrets.NEXUS_USER }}
PW: ${{ secrets.NEXUS_PW }}
run: |
# Publish the tarball
tarball=`ls *.gz`
version=`echo $tarball | sed -r 's/ldm-([0-9]+(\.[0-9]+)*)\.tar.gz/\1/'`
curl -u "$USER":"$PW" \
-T $tarball https://artifacts.unidata.ucar.edu/repository/downloads-ldm/$version/ \
-T $tarball https://artifacts.unidata.ucar.edu/repository/downloads-ldm/current/
# Update the information file on the source distributions if necessary
wget https://artifacts.unidata.ucar.edu/repository/downloads-ldm/release_info.json
if ! grep '"version": "'$version'",' release_info.json; then
sed -n '1,/"releases":/p' release_info.json >release_info.json.new
cat <<EOF >>release_info.json.new
{
"version": "$version",
"releaseDate": "`date +%Y-%m-%d`",
"status": "current",
"description": "",
"baseURL": "https://downloads.unidata.ucar.edu/ldm/$version/",
"resources": {
"jar": {
"type": "application",
"package": "$tarball",
"name": "GZipped TAR file",
"hash": {
"MD5": "",
"SHA1": "",
"SHA256": ""
},
"info": ""
}
}
},
EOF
sed -n '/"releases":/,$p' release_info.json | sed '1d' | sed 's/current/previous/' \
>>release_info.json.new
curl -u "$USER":"$PW" -T release_info.json.new \
https://artifacts.unidata.ucar.edu/repository/downloads-ldm/release_info.json
fi
# Publish the documentation
make install
cd /tmp/ldm/share/doc/ldm
find . -type f | sed 's/^\.\///' | while read path; do
curl -u "$USER":"$PW" \
-T $path https://artifacts.unidata.ucar.edu/repository/docs-ldm/$version/$path \
-T $path https://artifacts.unidata.ucar.edu/repository/docs-ldm/current/$path
done
# Update the versions file on the documentation if necessary
filename=versions.html
wget https://artifacts.unidata.ucar.edu/repository/docs-ldm/$filename
if ! grep -w '"version": "'$version'",' $filename; then
sed -n '1,/<tr>/p' $filename >$filename.new
cat <<EOF >>$filename.new
<td>
<b>$version</b>
</td>
<td>
<a href="https://docs.unidata.ucar.edu/ldm/$version/">Documentation</a>
</td>
<td>
<a href="https://downloads.unidata.ucar.edu/ldm/$version/ldm-$version.tar.gz">Download</a>
</td>
<td>
<a href="https://docs.unidata.ucar.edu/ldm/$version/CHANGE_LOG">Release Notes</a>
</td>
</tr>
EOF
sed -n '/<tr>/,$p' $filename | >>$filename.new
curl -u "$USER":"$PW" -T $filename.new \
https://artifacts.unidata.ucar.edu/repository/docs-ldm/$filename
fi