-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (140 loc) · 4.13 KB
/
ci.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
name: xrayAttenuation CI
on:
push:
paths:
- 'tests/**'
- 'src/**'
- 'docs/**'
- 'xrayAttenuation.nimble'
- '.github/workflows/ci.yml'
branches:
- 'master'
tags:
- 'v*' # Ensure it runs on tag push as well
pull_request:
paths:
- 'tests/**'
- 'src/**'
- 'docs/**'
- 'xrayAttenuation.nimble'
- '.github/workflows/ci.yml'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
nim:
#- '1.6.x'
- '2.0.x'
- 'devel'
os:
- ubuntu-latest
#- windows-latest
#- macOS-latest
name: '${{ matrix.nim }} (${{ matrix.os }})'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: xrayAttenuation
- name: Setup nim
uses: jiro4989/setup-nim-action@v1
with:
nim-version: ${{ matrix.nim }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies (Ubuntu)
if: ${{matrix.os == 'ubuntu-latest'}}
run: |
sudo apt-get update
sudo apt-get install musl musl-dev musl-tools
- name: Setup nimble & deps
shell: bash
run: |
cd xrayAttenuation
nimble refresh -y
nimble install -y
nimble ciDeps -y
- name: Run tests
shell: bash
run: |
cd xrayAttenuation
nimble -y test
- name: Build docs
if: ${{ matrix.docs == 'true' && matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
cd xrayAttenuation
branch=${{ github.ref }}
branch=${branch##*/}
nimble doc --project --outdir:docs \
'--git.url:https://github.com/${{ github.repository }}' \
'--git.commit:${{ github.sha }}' \
"--git.devel:$branch" \
xrayAttenuation.nim
# Ignore failures for older Nim
cp docs/{the,}index.html || true
- name: Publish docs
if: >
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.os == 'ubuntu-latest' && matrix.nim == 'devel'
uses: crazy-max/ghaction-github-pages@v1
with:
build_dir: xrayAttenuation/docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build examples
if: ${{ matrix.os == 'ubuntu-latest' && matrix.nim == '2.0.x' }}
shell: bash
run: |
cd xrayAttenuation/examples
nim c -d:musl -d:staticBuild -d:release calc_gas_mixtures.nim
- name: Upload example as artifact
uses: actions/upload-artifact@v3
with:
name: calc_gas_mixtures
path: xrayAttenuation/examples/calc_gas_mixtures
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
nim:
- '2.0.x'
os:
- ubuntu-latest
name: '${{ matrix.nim }} (${{ matrix.os }})'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: xrayAttenuation
- name: Download binary
uses: actions/download-artifact@v3
with:
name: calc_gas_mixtures
path: ./ # Specify the path to download the binary to
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release notes for version ${{ github.ref }}. See the \
changelog.org file for more information.
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./calc_gas_mixtures
asset_name: calc_gas_mixtures
asset_content_type: application/octet-stream