Skip to content

Commit 105644c

Browse files
authored
Merge pull request #246 from LKedward/release_builds
CI: upload binaries when a release is published
2 parents 2612d9a + 846d4e5 commit 105644c

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

.github/workflows/CI.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types: [published]
48

59
env:
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

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,31 @@ To report a bug report or suggest a feature, please read our
1717

1818
## Getting started
1919

20-
### Install Haskell
20+
### Binary download
21+
`x86-64` binaries are available [to download](https://github.com/fortran-lang/fpm/releases) for Windows, MacOS and Linux.
22+
23+
__Note:__ On Linux and MacOS, you will need to enable executable permission before you can use the binary.
24+
25+
_e.g._ `$ chmod u+x fpm-v0.1.0-linux-x86_64`
26+
27+
### Build from source
28+
29+
#### Install Haskell
2130

2231
To install **Haskell Stack**, follow these
2332
[instructions](https://docs.haskellstack.org/en/stable/install_and_upgrade/),
2433
users without superuser (admin) permissions should follow the
2534
[manual installation](https://docs.haskellstack.org/en/stable/install_and_upgrade/#manual-download_2)
2635
procedure.
2736

28-
### Download this repository
37+
#### Download this repository
2938

3039
```bash
3140
$ git clone https://github.com/fortran-lang/fpm
3241
$ cd fpm/
3342
```
3443

35-
### Build and test fpm
44+
#### Build and test fpm
3645

3746
Bootstrap *fpm* using:
3847

0 commit comments

Comments
 (0)