-
Notifications
You must be signed in to change notification settings - Fork 1
171 lines (143 loc) · 6.35 KB
/
build-and-deploy.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
name: "Build and publish CLI"
description: "Builds and pushes the CLI artifacts"
on:
workflow_call:
inputs:
STAGE:
required: true
default: 'staging'
VERSION:
required: true
default: '0.0.0'
secrets: inherit
env:
RUST_BACKTRACE: 1
WINDOWS_TARGET: x86_64-pc-windows-msvc
MACOS_TARGET: x86_64-apple-darwin
LINUX_TARGET: x86_64-unknown-linux-musl
BIN_DIR: bin
RELEASE_DIR: release
jobs:
compile-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install musl-tools
run: sudo apt-get install musl-tools
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-09-13
override: true
target: ${{ env.LINUX_TARGET }}
- name: Download cached dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "linux-cross-builds"
- name: Install cross
run: cargo install cross
- name: Inject Version
run: |
sh ./scripts/insert-cli-version.sh ${{ needs.get-version.outputs.full_version }}
- name: Build and Compress cli
run: |
mkdir ${{ env.BIN_DIR }}
mkdir ${{ env.RELEASE_DIR }}
cross build --release --all-features --target ${{ env.LINUX_TARGET }} -Z registry-auth
mv ./target/${{ env.LINUX_TARGET }}/release/ev-cage ./${{ env.BIN_DIR }}/ev-cage
7z a -ttar -so -an ./${{ env.BIN_DIR }} | 7z a -si ./${{ env.RELEASE_DIR }}/ev-cage-${{ env.LINUX_TARGET }}-${{ needs.get-version.outputs.full_version }}.tar.gz
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}
CARGO_HOME: ${{ github.workspace }}/.cargo
- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
name: linux
path: ./${{ env.RELEASE_DIR }}
compile-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Inject Version
run: |
sh ./scripts/insert-cli-version.sh ${{ needs.get-version.outputs.full_version }}
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-09-13
target: ${{ env.MACOS_TARGET }}
override: true
- name: Download cached dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "macos-cross-builds"
- name: Build CLI MacOs Target
run: |
cargo install cross
cross build --release --all-features --target ${{ env.MACOS_TARGET }} -Z registry-auth
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}
- name: Install 7z cli
run: brew install p7zip
- name: Setup directories
run: |
mkdir ${{ env.BIN_DIR }}
mkdir ${{ env.RELEASE_DIR }}
- name: Compress binary
run: |
mv target/${{env.MACOS_TARGET}}/release/ev-cage ${{ env.BIN_DIR }}/ev-cage
7z a -ttar -so -an ./${{ env.BIN_DIR }} | 7z a -si ${{ env.RELEASE_DIR }}/ev-cage-${{ env.MACOS_TARGET }}-${{ needs.get-version.outputs.full_version }}.tar.gz
- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
name: macos
path: ./${{ env.RELEASE_DIR }}
compile-windows:
runs-on: windows-latest
env:
VCPKGRS_DYNAMIC: 1
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update --no-self-update stable && rustup default stable
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-09-13
target: ${{ env.WINDOWS_TARGET }}
override: true
- name: Inject Version
run: |
sh ./scripts/insert-cli-version.sh ${{ needs.get-version.outputs.full_version }}
- name: Download cached dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "windows-cross-builds"
- name: Fetch dependencies
run: cargo fetch -Z registry-auth
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}
- name: Build CLI for Windows
run: |
cargo install cross
cross build --release --all-features --target ${{ env.WINDOWS_TARGET }} -Z registry-auth
env:
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_INDEX: ${{ secrets.RUST_CRYPTO_REGISTRY }}
CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN: ${{ secrets.CARGO_REGISTRIES_EVERVAULT_RUST_LIBRARIES_TOKEN }}
- name: Setup directories
shell: bash
run: |
mkdir ${{ env.BIN_DIR }}
mkdir ${{ env.RELEASE_DIR }}
- name: Compress
shell: bash
run: |
mv target/${{ env.WINDOWS_TARGET }}/release/ev-cage.exe ${{ env.BIN_DIR }}/ev-cage.exe
7z a -ttar -so -an ./${{ env.BIN_DIR }} | 7z a -si ./${{ env.RELEASE_DIR }}/ev-cage-${{ env.WINDOWS_TARGET }}-${{ needs.get-version.outputs.full_version }}.tar.gz
- name: Upload as artifact
uses: actions/upload-artifact@v2
with:
name: windows
path: ./${{ env.RELEASE_DIR }}