11name : CI
22
3- on : [push, pull_request]
3+ on :
4+ push :
5+ pull_request :
6+ release :
7+ types : [published]
48
59env :
610 CI : " ON" # We can detect this in the build system and other vendors implement it
@@ -23,16 +27,33 @@ jobs:
2327 - os : ubuntu-latest
2428 STACK_CACHE : " /home/runner/.stack/"
2529 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+
2636 - os : macos-latest
2737 STACK_CACHE : |
2838 /Users/runner/.stack/snapshots
2939 /Users/runner/.stack/setup-exe-src
3040 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+
3147 - os : windows-latest
3248 STACK_CACHE : |
3349 C:\Users\runneradmin\AppData\Roaming\stack
3450 C:\Users\runneradmin\AppData\Local\Programs\stack
3551 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"))}
3657
3758 env :
3859 FC : gfortran
@@ -104,3 +125,29 @@ jobs:
104125 if : contains(matrix.os, 'windows')
105126 run : |
106127 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