-
Notifications
You must be signed in to change notification settings - Fork 9
128 lines (124 loc) · 4.32 KB
/
ci.yaml
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
name: CI
on:
push:
branches: [main]
tags: [v*]
pull_request:
branches: [main]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}
- run: rustup component add clippy
- run: rustup component add rustfmt-preview
- run: cargo test --locked
- run: cargo clippy --all-targets --all-features
- run: cargo fmt --all -- --check
build_cross:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Raspberry pi
target: armv7-unknown-linux-musleabihf
# Cross currently doesn't include openssl for this particular
# target, so we can't really make this work that easily.
# When isahc ships with rusttls support, tho, we can adopt that
# and more easily cross compile for platforms like FreeBSD!
# - name: FreeBSD
# target: x86_64-unknown-freebsd
env:
RUSTFLAGS: "-C link-arg=-s"
steps:
- uses: actions/checkout@v2
- run: cargo install cross
- run: cross build --release --target ${{ matrix.target }} --locked
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash
- run: |
7z a elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar elm-json
7z a elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar
working-directory: target/${{ matrix.target }}/release
- name: Store binary as artifact
uses: actions/upload-artifact@v2
with:
name: elm-json-${{ matrix.target }}
path: target/${{ matrix.target }}/release/elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
build:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
include:
- name: Linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
ext: ""
- name: OSX (intel)
os: macos-11
target: x86_64-apple-darwin
ext: ""
- name: OSX (arm)
os: macos-11
target: aarch64-apple-darwin
ext: ""
- name: Windows
os: windows-latest
target: x86_64-pc-windows-msvc
ext: ".exe"
env:
RUSTFLAGS: "-C link-arg=-s"
runs-on: ${{ matrix.os }}
steps:
- name: Install MUSL target
if: ${{ matrix.name == 'Linux' }}
run: sudo apt update && sudo apt install musl-tools
- uses: actions/checkout@v2
- run: rustup target add ${{ matrix.target }}
- run: cargo build --release --target ${{ matrix.target }} --locked
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash
- run: |
7z a elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar elm-json${{ matrix.ext }}
7z a elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar
working-directory: target/${{ matrix.target }}/release
- name: Store binary as artifact
uses: actions/upload-artifact@v2
with:
name: elm-json-${{ matrix.target }}
path: target/${{ matrix.target }}/release/elm-json-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz
create_release:
needs: [build, build_cross]
if: startsWith(github.ref, 'refs/tags/v')
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- name: Display structure of downloaded files
run: ls -R
- name: Release
uses: softprops/action-gh-release@v1
with:
files: elm-json-*/elm-json-*.tar.gz