-
Notifications
You must be signed in to change notification settings - Fork 13
126 lines (120 loc) · 5.19 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
on: [push, pull_request]
jobs:
build:
name: ${{ matrix.job.os }} (${{ matrix.job.target }})
runs-on: ${{ matrix.job.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
job:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl, use-cross: true }
- { os: ubuntu-20.04, target: x86_64-unknown-linux-musl, use-cross: true }
- { os: macos-latest, target: x86_64-apple-darwin }
- { os: macos-latest, target: aarch64-apple-darwin, use-cross: true }
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true # recurse submodules
- name: Configure Environment
run: |
case ${{ matrix.job.target }} in
*-pc-windows-gnu)
case ${{ matrix.job.target }} in
i686*)
MSYSTEM=MINGW32
MSYSTEM_PATH=c:/msys64/mingw32
;;
x86_64*)
MSYSTEM=MINGW64
MSYSTEM_PATH=c:/msys64/mingw64
;;
esac
echo "c:/msys64" >> $GITHUB_PATH # enable msys2 entrypoint commands (probably not needed)
echo "c:/msys64/usr/bin" >> $GITHUB_PATH # place msys2 environment on system path
echo "${MSYSTEM_PATH}/bin" >> $GITHUB_PATH # place MinGW environment on system path
echo "CHERE_INVOKING=yes" >> $GITHUB_ENV # maintain directory context
echo "MSYSTEM=${MSYSTEM}" >> $GITHUB_ENV # set msystem version for msys2 shell
;;
esac
- name: Install Prerequisites
run: |
case ${{ matrix.job.target }} in
x86_64-pc-windows-gnu)
pacman -S --noconfirm --needed mingw-w64-x86_64-gcc base-devel autoconf
;;
i686-pc-windows-gnu)
pacman -S --noconfirm --needed mingw-w64-i686-gcc base-devel autoconf
;;
*-unknown-linux-*)
sudo apt-get -y update
sudo apt-get -y install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf musl-tools gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
pip install cargo-zigbuild
;;
*-apple-darwin)
brew install automake
;;
esac
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.job.toolchain || 'stable' }}
target: ${{ matrix.job.target }}
override: true
default: true
components: rustfmt, clippy
- name: Build Libsodium
if: contains(matrix.job.features, 'libsodium-sys')
run: autoreconf -vfi && ./configure && make && make install
working-directory: contrib/libsodium
- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Lint (Clippy)
uses: actions-rs/cargo@v1
with:
command: clippy
args: --release --features "${{ join(matrix.job.features, ',') }}" --target ${{ matrix.job.target }} -- -D warnings
- name: Test
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: test
args: --release --features "${{ join(matrix.job.features, ',') }}" --target ${{ matrix.job.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --features "${{ join(matrix.job.features, ',') }}" --target ${{ matrix.job.target }} --locked
- name: Package
id: package
run: |
PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml)
PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
PKG_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_SUFFIX=".zip" ;; esac;
PKG_NAME=${PROJECT_NAME}-${PROJECT_VERSION}-${{ matrix.job.target }}${PKG_SUFFIX}
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z -y a "${PKG_NAME}" ./target/${{matrix.job.target}}/release/cncli.exe | tail -2 ;;
*) tar -C target/${{matrix.job.target}}/release -czf "${PKG_NAME}" cncli ;;
esac;
echo ::set-output name=PKG_NAME::${PKG_NAME}
echo ::set-output name=PKG_PATH::${PKG_NAME}
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.PKG_NAME }}
path: ${{ steps.package.outputs.PKG_PATH }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: ${{ steps.package.outputs.PKG_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}