-
Notifications
You must be signed in to change notification settings - Fork 16
270 lines (245 loc) · 10.4 KB
/
build-ss3.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# Builds the stock synthesis executables for testing and distribution using the admb docker image.
# for macOS 12, and macos-14 (arm64 architecture), linux, Windows
# Runs on every push and PR (even draft PRs)
name: build-ss3
on:
push:
paths:
- '**.tpl'
- '**.sh'
workflow_dispatch:
jobs:
build-ss3:
if: ${{ github.event_name == 'workflow_dispatch' || github.event == 'push' || github.event.workflow_run.conclusion == 'failure' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest}
- {os: macos-13}
- {os: macos-latest}
- {os: ubuntu-latest}
# Limit run time to 90 min to avoid wasting action minutes.
# was set to 15 and then 30 minutes previously, but compiling admb
# on mac took too long
timeout-minutes: 90
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout ss3 repo
uses: actions/checkout@v4
with:
repository: 'nmfs-ost/ss3-source-code'
# Checkout ADMB repository
- name: Checkout admb for macos-13 build
uses: actions/checkout@v4
with:
repository: admb-project/admb
path: admb
ref: admb-13.2
- name: Update Ubuntu packages
if: matrix.config.os == 'ubuntu-latest'
run: sudo apt-get update
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Fetch git tags
run: |
git fetch --tags
git fetch --prune --unshallow || true
# Build ADMB for macos-13
- name: Build ADMB for macos-13 and put in path
if: matrix.config.os == 'macos-13'
run: |
cd admb && make clean
- name: See where admb is
if: matrix.config.os == 'macos-13'
run: |
cd admb && ls
- name: Compile admb, macOS
if: matrix.config.os == 'macos-13'
run: |
cd admb && make -j 4
- name: Change permissions of admb and put in path, macOS
if: matrix.config.os == 'macos-13'
run: |
sudo mv admb /usr/local/bin
sudo chmod 755 /usr/local/bin/admb
echo "/usr/local/bin/admb" >> $GITHUB_PATH
- name: Get the last tag on Windows
id: get-latest-tag-win
if: matrix.config.os == 'windows-latest'
run: |
git tag
$latest_tag = (git describe --abbrev=0 --tags)
$latest_tag_commit = ( git rev-list -n 1 $latest_tag)
$latest_commit = (git rev-list HEAD -n 1)
echo "tag=${latest_tag}" >> $env:GITHUB_OUTPUT
echo "tag_commit=${latest_tag_commit}" >> $env:GITHUB_OUTPUT
echo "commit=${latest_commit}" >> $env:GITHUB_OUTPUT
- name: Pull the last tag value to use in the Rscript on Windows
id: get-version-win
if: matrix.config.os == 'windows-latest'
run: |
Out-File -InputObject ${{ steps.get-latest-tag-win.outputs.tag }} -FilePath .github/last_tag.txt
Out-File -InputObject ${{ steps.get-latest-tag-win.outputs.tag_commit }} -FilePath .github/last_tag_commit.txt
Out-File -InputObject ${{ steps.get-latest-tag-win.outputs.commit}} -FilePath .github/last_commit.txt
- name: Get the last tag on unix (macOS and linux)
id: get-latest-tag-unix
if: matrix.config.os == 'macos-13' || matrix.config.os == 'macos-latest' || matrix.config.os == 'ubuntu-latest'
run: |
git tag
latest_tag=$(git describe --abbrev=0 --tags)
latest_tag_commit=$(git rev-list -n 1 $latest_tag)
latest_commit=$(git rev-list HEAD -n 1)
echo "tag=${latest_tag}" >> $GITHUB_OUTPUT
echo "tag_commit=${latest_tag_commit}" >> $GITHUB_OUTPUT
echo "commit=${latest_commit}" >> $GITHUB_OUTPUT
- name: Pull the last tag value to use in the Rscript on unix (macOS and linux)
id: get-version-unix
if: matrix.config.os == 'macos-13' || matrix.config.os == 'macos-latest' || matrix.config.os == 'ubuntu-latest'
run: |
echo "${{ steps.get-latest-tag-unix.outputs.tag }}" > .github/last_tag.txt
echo "${{ steps.get-latest-tag-unix.outputs.tag_commit }}" > .github/last_tag_commit.txt
echo "${{ steps.get-latest-tag-unix.outputs.commit }}" > .github/last_commit.txt
- name: Edit the version info for safe version using R code
run: |
# Get the version
# get the last tag from the repository
tag_label <- readLines(".github/last_tag.txt")
# get commits from from the repository
tag_commit <- readLines(".github/last_tag_commit.txt")
last_commit <- readLines(".github/last_commit.txt")
message("The tag_label is ", tag_label)
if (substr(tag_label, start = 1, stop = 6) == "v3.30.") {
ver_num_full <- strsplit(tag_label, split = "v3.30", fixed = TRUE)[[1]][2]
ver_num <- strsplit(ver_num_full, split = ".", fixed = TRUE)[[1]][2]
if(length(grep("-", ver_num)) > 0) {
ver_num <- strsplit(ver_num, split = "-", fixed = TRUE)[[1]][1]
}
} else {
ver_num <- "unknown"
}
message("tag commit: ", tag_commit)
message("last commit: ", last_commit)
if(tag_commit == last_commit) {
# figure out the version using the tag
if(ver_num == "unknown") {
fix_ver_num <- "unknown"
} else {
ver_num_full_split <- strsplit(ver_num_full, split = ".", fixed = TRUE)[[1]]
if(length(ver_num_full_split) == 3) {
fix_ver_num <- ver_num_full_split[3]
} else if(length(ver_num_full_split) == 2) {
if(length(grep("-", ver_num_full_split, fixed = TRUE)) > 0) {
fix_ver_num <- strsplit(ver_num_full_split[2], split = "-", fixed = TRUE)[[1]][2]
fix_ver_num <- paste0("00-", fix_ver_num)
} else {
fix_ver_num <- "00"
}
} else {
fix_ver_num <- "unknown"
}
}
} else {
fix_ver_num <- "beta: not an official version of SS"
}
message("The minor version label is ", ver_num)
message("The patch version label is ", fix_ver_num)
# add version numbers to files
# safe file
ver_info <- readLines("SS_versioninfo_330safe.tpl")
ver_info_start <- grep('Create string with version info', ver_info, fixed = TRUE)
ver_info[ver_info_start + 1] <-
gsub('\\.xx', paste0('\\.', ver_num), ver_info[ver_info_start + 1])
ver_info[ver_info_start + 1] <-
gsub('\\.yy', paste0('\\.', fix_ver_num), ver_info[ver_info_start+1])
writeLines(ver_info, "SS_versioninfo_330safe.tpl")
#opt file
ver_info <- readLines("SS_versioninfo_330opt.tpl")
ver_info_start <- grep('Create string with version info', ver_info, fixed = TRUE)
ver_info[ver_info_start + 1] <-
gsub('\\.xx', paste0('\\.', ver_num), ver_info[ver_info_start + 1])
ver_info[ver_info_start + 1] <-
gsub('\\.yy', paste0('\\.', fix_ver_num), ver_info[ver_info_start+1])
writeLines(ver_info, "SS_versioninfo_330opt.tpl")
shell: Rscript {0}
- name: Build stock synthesis for windows with admb docker image
if: matrix.config.os == 'windows-latest'
run: |
cd Compile
./Make_SS_fast.bat || true
./Make_SS_safe.bat || true
cd ..
- name: Move exes to a new folder on windows
if: matrix.config.os == 'windows-latest'
run: |
mkdir SS330
chmod 777 SS330
mv Compile/ss3.exe SS330/
mv Compile/ss3_opt.exe SS330/
mv SS330/ss3.exe SS330/ss3_win.exe
mv SS330/ss3_opt.exe SS330/ss3_opt_win.exe
- name: Build stock synthesis for mac with admb from source
if: matrix.config.os == 'macos-13'
run: |
rm -rf SS330
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh -b SS330
/bin/bash ./Make_SS_330_new.sh -b SS330 -o
- name: Build stock synthesis for mac m2 with admb docker image
if: matrix.config.os == 'macos-latest'
run: |
brew update
brew install docker
brew install --head colima
colima start --arch x86_64
docker pull johnoel/admb-13.2:linux
rm -rf SS330
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -o
- name: Verify binary on mac
if: matrix.config.os == 'macos-13' || matrix.config.os == 'macos-latest'
run: |
shasum -a 256 SS330/ss3
shasum -a 256 SS330/ss3_opt
- name: Delete unneeded files and change exe names on mac
if: matrix.config.os == 'macos-13' || matrix.config.os == 'macos-latest'
run: |
cd SS330
rm *.obj *.htp *.cpp ss3_opt.tpl
mv ss3 ss3_osx
mv ss3_opt ss3_opt_osx
- name: Build stock synthesis for linux with p flag and admb docker image
if: matrix.config.os == 'ubuntu-latest'
run: |
rm -rf SS330
rm -rf ss3_osx.tar
mkdir SS330
chmod 777 SS330
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -p
/bin/bash ./Make_SS_330_new.sh --admb docker -b SS330 -o -p
- name: Verify binary on linux
if: matrix.config.os == 'ubuntu-latest'
run: |
sha256sum SS330/ss3
sha256sum SS330/ss3_opt
- name: Delete unneeded files and change exe names on linux
if: matrix.config.os == 'ubuntu-latest'
run: |
cd SS330
rm *.obj *.htp *.cpp ss3_opt.tpl ss3.tpl
mv ss3 ss3_linux
mv ss3_opt ss3_opt_linux
- name: Archive binaries
if: success()
uses: actions/upload-artifact@main
with:
name: ss3-${{ matrix.config.os }}
path: SS330/