1
1
name : CI
2
2
3
- on : [push, pull_request]
3
+ on :
4
+ push :
5
+ pull_request :
6
+ release :
7
+ types : [published]
4
8
5
9
env :
6
10
CI : " ON" # We can detect this in the build system and other vendors implement it
@@ -23,16 +27,33 @@ jobs:
23
27
- os : ubuntu-latest
24
28
STACK_CACHE : " /home/runner/.stack/"
25
29
STACK_CACHE_VERSION : " "
30
+ GET_VERSION_CMD : echo ${{ github.ref }} | cut -dv -f2
31
+ CHECK_VERSION_CMD : grep $(cat fpm_version)
32
+ RELEASE_CMD : " fpm run --flag --static --flag -g --flag -fbacktrace --flag -O3 --runner cp -- fpm-v$(cat fpm_version)-linux-x86_64"
33
+ BOOTSTRAP_RELEASE_CMD : cp /home/runner/.local/bin/fpm fpm-bootstrap-v$(cat fpm_version)-linux-x86_64
34
+ HASH_CMD : ls fpm-*|xargs -i{} sh -c 'sha256sum $1 > $1.sha256' -- {}
35
+
26
36
- os : macos-latest
27
37
STACK_CACHE : |
28
38
/Users/runner/.stack/snapshots
29
39
/Users/runner/.stack/setup-exe-src
30
40
STACK_CACHE_VERSION : " v2"
41
+ GET_VERSION_CMD : echo ${{ github.ref }} | cut -dv -f2
42
+ CHECK_VERSION_CMD : grep $(cat fpm_version)
43
+ RELEASE_CMD : " fpm run --flag -g --flag -fbacktrace --flag -O3 --runner cp -- fpm-v$(cat fpm_version)-macos-x86_64"
44
+ BOOTSTRAP_RELEASE_CMD : cp /Users/runner/.local/bin/fpm fpm-bootstrap-v$(cat fpm_version)-macos-x86_64
45
+ HASH_CMD : ls fpm-*|xargs -I{} sh -c 'shasum -a 256 $1 > $1.sha256' -- {}
46
+
31
47
- os : windows-latest
32
48
STACK_CACHE : |
33
49
C:\Users\runneradmin\AppData\Roaming\stack
34
50
C:\Users\runneradmin\AppData\Local\Programs\stack
35
51
STACK_CACHE_VERSION : " v2"
52
+ GET_VERSION_CMD : ("${{ github.ref }}" -Split "v")[1]
53
+ CHECK_VERSION_CMD : Select-String -Pattern Version | Where-Object { if ($_ -like -join("*",(Get-Content fpm_version),"*")) {echo $_} else {Throw} }
54
+ RELEASE_CMD : fpm run --flag --static --flag -g --flag -fbacktrace --flag -O3 --runner copy -- (-join("fpm-v",(Get-Content fpm_version),"-windows-x86_64.exe"))
55
+ BOOTSTRAP_RELEASE_CMD : copy C:\Users\runneradmin\AppData\Roaming\local\bin\fpm.exe (-join("fpm-bootstrap-v",(Get-Content fpm_version),"-windows-x86_64.exe"))
56
+ HASH_CMD : Get-ChildItem -File -Filter "fpm-*" | Foreach-Object {echo (Get-FileHash -Algorithm SHA256 $PSItem | Select-Object hash | Format-Table -HideTableHeaders | Out-String) > (-join($PSItem,".sha256"))}
36
57
37
58
env :
38
59
FC : gfortran
@@ -104,3 +125,29 @@ jobs:
104
125
if : contains(matrix.os, 'windows')
105
126
run : |
106
127
ci\run_tests.bat
128
+
129
+ # ----- Upload binaries if creating a release -----
130
+ - name : Check that fpm --version matches release tag
131
+ if : github.event_name == 'release'
132
+ run : |
133
+ cd fpm
134
+ ${{ matrix.GET_VERSION_CMD }} > fpm_version
135
+ fpm run -- "--version" | ${{ matrix.CHECK_VERSION_CMD }}
136
+
137
+ - name : Stage release files for upload
138
+ if : github.event_name == 'release'
139
+ run : |
140
+ cd fpm
141
+ ${{ matrix.RELEASE_CMD }}
142
+ ${{ matrix.BOOTSTRAP_RELEASE_CMD }}
143
+ ${{ matrix.HASH_CMD }}
144
+
145
+ - name : Upload assets
146
+ if : github.event_name == 'release'
147
+ uses : svenstaro/upload-release-action@v2
148
+ with :
149
+ repo_token : ${{ secrets.GITHUB_TOKEN }}
150
+ file : fpm/fpm-*
151
+ file_glob : true
152
+ tag : ${{ github.ref }}
153
+ overwrite : true
0 commit comments