-
Notifications
You must be signed in to change notification settings - Fork 6
182 lines (165 loc) · 6.02 KB
/
builds.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
name: "build binaries"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
branches:
- build-*
schedule:
- cron: "05 00 * * 1"
workflow_dispatch:
inputs:
customTag:
description: "Main Tag"
required: true
default: "main-tag"
env:
APP_FILENAME: "p2p-chess"
jobs:
builds:
name: Build and upload Binaries
strategy:
fail-fast: false
matrix:
build:
[
linux-x86_64, linux-arm64,
macos-x86_64, macos-arm64,
windows-x64, windows-arm64,
]
include:
- build: linux-x86_64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
- build: linux-arm64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
cross: false
- build: macos-x86_64
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- build: macos-arm64
os: macos-latest
rust: stable
target: aarch64-apple-darwin
cross: false
- build: windows-x64
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
cross: false
- build: windows-arm64
os: windows-latest
rust: stable
target: aarch64-pc-windows-msvc
cross: false
exclude:
- build: [ linux-arm64, windows-arm64, ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Declare Global Variables 4 GHA ${{ github.event_name }}
id: vars
shell: bash
run: |
echo "VBRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "VSHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt, clippy
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Install Linux dependencies - Ubuntu
if: startsWith(runner.os,'Linux')
run: |
sudo apt-get update
sudo apt-get -y install \
openssl \
libssl-dev \
pkg-config \
libsqlite3-dev \
libasound-dev \
librust-alsa-sys-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev
- name: Install macOS dependencies
if: startsWith(runner.os,'macOS')
run: brew install cmake zip coreutils automake autoconf
- name: Install Windows dependencies
if: startsWith(runner.os,'Windows')
run: |
vcpkg.exe install sqlite3:x64-windows zlib:x64-windows
choco upgrade llvm zip psutils openssl strawberryperl -y
- name: Set environment variables - Nix
if: "!startsWith(runner.os,'Windows')"
run: |
echo "SHARUN=shasum --algorithm 256" >> $GITHUB_ENV
echo "CC=gcc" >> $GITHUB_ENV
echo "APP_EXT=" >> $GITHUB_ENV
echo "SHELL_EXT=.sh" >> $GITHUB_ENV
echo "PLATFORM_SPECIFIC_DIR=linux" >> $GITHUB_ENV
echo "APP_DIST=/dist" >> $GITHUB_ENV
- name: Set environment variables - Windows
if: startsWith(runner.os,'Windows')
shell: bash
run: |
echo "SHARUN=pwsh C:\ProgramData\chocolatey\lib\psutils\tools\psutils-master\shasum.ps1 --algorithm 256" >> $GITHUB_ENV
echo "APP_EXT=.exe" >> $GITHUB_ENV
echo "LIB_PRE=" >> $GITHUB_ENV
echo "SHELL_EXT=.bat" >> $GITHUB_ENV
echo "APP_DIST=\dist" >> $GITHUB_ENV
echo "PLATFORM_SPECIFIC_DIR=windows" >> $GITHUB_ENV
echo "SQLITE3_LIB_DIR=C:\vcpkg\installed\x64-windows\lib" >> $GITHUB_ENV
echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >> $GITHUB_ENV
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV
echo "C:\Strawberry\perl\bin" >> $GITHUB_PATH
- name: Cache cargo files and outputs
uses: Swatinem/rust-cache@v1
- name: Build target binaries
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Copy binaries to folder for zipping
shell: bash
run: |
mkdir -p "$GITHUB_WORKSPACE${APP_DIST}"
cd "$GITHUB_WORKSPACE${APP_DIST}"
VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' "$GITHUB_WORKSPACE/app/Cargo.toml")
echo "Branch: ${VBRANCH}"
echo "Sha: ${VSHA_SHORT}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VSHA_SHORT=${VSHA_SHORT}" >> $GITHUB_ENV
BINFILE="${APP_FILENAME}-${VERSION}-${VSHA_SHORT}-${{ matrix.os }}${APP_EXT}"
echo "BINFILE=${BINFILE}" >> $GITHUB_ENV
echo "Copying files for ${BINFILE} to $(pwd)"
ls -la "$GITHUB_WORKSPACE/target/${{ matrix.target }}/release/"
cp -v "$GITHUB_WORKSPACE/target/${{ matrix.target }}/release/${{ env.APP_FILENAME }}${APP_EXT}" .
- name: Archive and Checksum Binaries
shell: bash
run: |
echo "Archive ${{ env.BINFILE }} too ${{ env.BINFILE }}.zip"
cd "$GITHUB_WORKSPACE${{ env.APP_DIST }}"
zip -j "${{ env.BINFILE }}.zip" *
echo "Compute shasum"
${SHARUN} "${{ env.BINFILE }}.zip" >> "${{ env.BINFILE }}.zip.sha256"
cat "${{ env.BINFILE }}.zip.sha256"
echo "Verifications is "
${SHARUN} --check "${{ env.BINFILE }}.zip.sha256"
- name: Artifact upload for Archive
uses: actions/upload-artifact@v2
with:
name: ${{ env.APP_FILENAME }}_archive-${{ matrix.os }}-${{ matrix.target }}.zip
path: "${{ github.workspace }}${{ env.APP_DIST }}/${{ env.BINFILE }}.zip*"