-
Notifications
You must be signed in to change notification settings - Fork 2
192 lines (163 loc) · 5.59 KB
/
release.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
183
184
185
186
187
188
189
190
191
192
name: Release Client
on:
push:
branches:
- '**'
tags:
- 'v*'
paths:
- '.github/workflows/release.yml'
- 'wazuh-cert-oauth2-client/**'
- 'wazuh-cert-oauth2-model/**'
jobs:
build-ubuntu:
name: Build CLI
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: |
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-${{ matrix.target }}-
- name: Install cross
run: cargo install cross
- name: Build with cross
run: cross build --release --target ${{ matrix.target }}
working-directory: wazuh-cert-oauth2-client
- name: Rename resource
run: mv wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client wazuh-cert-oauth2-client-${{ matrix.target }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: wazuh-cert-oauth2-client-${{ matrix.target }}
path: wazuh-cert-oauth2-client-${{ matrix.target }}
build-macos:
name: Build CLI for macOS
runs-on: macos-latest
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: |
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-${{ matrix.target }}-
- name: Install macOS target
run: rustup target add ${{ matrix.target }}
- name: Build with cargo
run: cargo build --release --target ${{ matrix.target }}
working-directory: wazuh-cert-oauth2-client
- name: Rename resource
run: mv wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client wazuh-cert-oauth2-client-${{ matrix.target }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: wazuh-cert-oauth2-client-${{ matrix.target }}
path: wazuh-cert-oauth2-client-${{ matrix.target }}
build-windows:
name: Build CLI for Windows
runs-on: windows-latest
strategy:
matrix:
target:
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v4
with:
path: |
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-${{ matrix.target }}-
- name: Install Windows target
run: rustup target add ${{ matrix.target }}
- name: Build with cargo
run: cargo build --release --target ${{ matrix.target }}
working-directory: wazuh-cert-oauth2-client
- name: Rename resource
run: mv wazuh-cert-oauth2-client/target/${{ matrix.target }}/release/wazuh-cert-oauth2-client.exe wazuh-cert-oauth2-client-${{ matrix.target }}.exe
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: wazuh-cert-oauth2-client-${{ matrix.target }}
path: wazuh-cert-oauth2-client-${{ matrix.target }}.exe
release:
name: Release
permissions: write-all
needs:
- build-ubuntu
- build-macos
- build-windows
runs-on: ubuntu-latest
steps:
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Create Release
id: create_release
uses: actions/create-release@v1
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: .
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: '**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}