-
Notifications
You must be signed in to change notification settings - Fork 6
206 lines (178 loc) · 6.38 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Release
on:
workflow_dispatch:
permissions:
contents: write
jobs:
check-user:
name: Check Team affiliation and Branch
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check Team affiliation and Branch
uses: ./.github/actions/check-team-affiliation-and-branch
with:
ref: ${{ github.ref }}
actor: ${{ github.actor }}
github_token: ${{ secrets.PAT }}
build-macos:
needs: check-user
runs-on: macos-latest
strategy:
matrix:
target: [aarch64-apple-darwin]
name: Build / MacOS / ${{ matrix.target }}
steps:
- name: (checkout) source code
uses: actions/checkout@v4
- name: (run) build
uses: ./.github/actions/build
with:
target: ${{ matrix.target }}
use-cache: false
github-token: ${{ secrets.GITHUB_TOKEN }}
build-linux:
needs: check-user
runs-on: ubuntu-latest
outputs:
upload_deb_name: ${{ steps.output_deb.outputs.upload_deb_name }}
strategy:
matrix:
target: [x86_64-unknown-linux-gnu]
name: Build / Linux / ${{ matrix.target }}
steps:
- name: (checkout) source code
uses: actions/checkout@v4
- name: (run) build
uses: ./.github/actions/build-with-cross
with:
target: ${{ matrix.target }}
use-cache: true
binary-file-name: nodex-agent
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install `cargo-get`
run: cargo install cargo-get
shell: bash
- name: (run) Output package name for release
run: |
PACKAGE_NAME="nodex-agent"
VERSION=$(cargo get package.version)
ARCHITECTURE=$(dpkg --print-architecture)
UPLOAD_DEB_NAME="${PACKAGE_NAME}_${VERSION}_${ARCHITECTURE}.deb"
echo "UPLOAD_DEB_NAME=$UPLOAD_DEB_NAME" >> $GITHUB_ENV
shell: bash
- name: (run) build with omnibus
uses: ./.github/actions/build-with-omnibus
with:
use-cache: true
platform: ubuntu
arch: ${{ matrix.target }}
release-package-name: ${{ env.UPLOAD_DEB_NAME }}
package-format: deb
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: (run) Output deb name for release
id: output_deb
run: echo "upload_deb_name=${{ env.UPLOAD_DEB_NAME }}" >> $GITHUB_OUTPUT
build-windows:
needs: check-user
runs-on: windows-latest
strategy:
matrix:
target: [x86_64-pc-windows-msvc]
name: Build / Windows / ${{ matrix.target }}
steps:
- name: (checkout) source code
uses: actions/checkout@v4
- name: (run) build
uses: ./.github/actions/build-with-cross
with:
target: ${{ matrix.target }}
use-cache: false
binary-file-name: nodex-agent.exe
github-token: ${{ secrets.GITHUB_TOKEN }}
release:
name: Release
needs: [build-macos, build-linux, build-windows]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install `cargo-get`
run: cargo install cargo-get
- name: Set Crate Version as Environment Variable
id: set_crate_version
run: |
CARGO_TOML_VERSION=$(cargo get package.version)
echo "version=$CARGO_TOML_VERSION" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}
merge-multiple: true
- name: Check downloaded artifacts
run: |
ls -la ${{ github.workspace }}
- name: Create Example asset
shell: bash
working-directory: examples
run: |
zip -r example.zip nodejs/ python/ systemd/ ../../LICENSE
- name: Create Release
uses: actions/github-script@v5
id: release
with:
result-encoding: string
script: |
const fs = require('fs').promises;
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "v${{ steps.set_crate_version.outputs.version }}",
generate_release_notes: true
});
return release.data.id;
- name: Upload asset (linux)
uses: ./.github/actions/upload-release-asset
with:
release_id: ${{ steps.release.outputs.result }}
asset_path: ${{ github.workspace }}/nodex-agent-x86_64-unknown-linux-gnu.zip
asset_name: nodex-agent-x86_64.zip
asset_content_type: application/zip
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload asset (deb)
uses: ./.github/actions/upload-release-asset
with:
release_id: ${{ steps.release.outputs.result }}
asset_path: ${{ github.workspace }}/${{ needs.build-linux.outputs.upload_deb_name }}
asset_name: ${{ needs.build-linux.outputs.upload_deb_name }}
asset_content_type: application/vnd.debian.binary-package
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload asset (mac)
uses: ./.github/actions/upload-release-asset
with:
release_id: ${{ steps.release.outputs.result }}
asset_path: ${{ github.workspace }}/nodex-agent-aarch64-apple-darwin.zip
asset_name: nodex-agent-mac.zip
asset_content_type: application/zip
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload asset (windows)
uses: ./.github/actions/upload-release-asset
with:
release_id: ${{ steps.release.outputs.result }}
asset_path: ${{ github.workspace }}/nodex-agent-x86_64-pc-windows-msvc.zip
asset_name: nodex-agent-x86_64-windows.zip
asset_content_type: application/zip
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload asset (example)
uses: ./.github/actions/upload-release-asset
with:
release_id: ${{ steps.release.outputs.result }}
asset_path: ./examples/example.zip
asset_name: example.zip
asset_content_type: application/zip
github_token: ${{ secrets.GITHUB_TOKEN }}