-
Notifications
You must be signed in to change notification settings - Fork 1.1k
154 lines (128 loc) · 5.15 KB
/
gnd-binary-build.yml
File metadata and controls
154 lines (128 loc) · 5.15 KB
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
name: Build gnd Binaries
on:
workflow_dispatch:
jobs:
build:
name: Build gnd for ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-22.04
asset_name: gnd-linux-x86_64
- target: aarch64-unknown-linux-gnu
runner: ubuntu-22.04
asset_name: gnd-linux-aarch64
- target: x86_64-apple-darwin
runner: macos-13
asset_name: gnd-macos-x86_64
- target: aarch64-apple-darwin
runner: macos-latest
asset_name: gnd-macos-aarch64
- target: x86_64-pc-windows-msvc
runner: windows-latest
asset_name: gnd-windows-x86_64.exe
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup toolchain install stable
rustup target add ${{ matrix.target }}
rustup default stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install dependencies (Ubuntu)
if: startsWith(matrix.runner, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler musl-tools
- name: Install dependencies (macOS)
if: startsWith(matrix.runner, 'macos')
run: |
brew install protobuf
- name: Install protobuf (Windows)
if: startsWith(matrix.runner, 'windows')
run: choco install protoc
- name: Build gnd binary (Unix/Mac)
if: ${{ !startsWith(matrix.runner, 'windows') }}
run: cargo build --bin gnd --release --target ${{ matrix.target }}
- name: Build gnd binary (Windows)
if: startsWith(matrix.runner, 'windows')
run: cargo build --bin gnd --release --target ${{ matrix.target }}
- name: Sign macOS binary
if: startsWith(matrix.runner, 'macos')
uses: lando/code-sign-action@v3
with:
file: target/${{ matrix.target }}/release/gnd
certificate-data: ${{ secrets.APPLE_CERT_DATA }}
certificate-password: ${{ secrets.APPLE_CERT_PASSWORD }}
certificate-id: ${{ secrets.APPLE_TEAM_ID }}
options: --options runtime --entitlements entitlements.plist
- name: Notarize macOS binary
if: startsWith(matrix.runner, 'macos')
uses: lando/notarize-action@v2
with:
product-path: target/${{ matrix.target }}/release/gnd
appstore-connect-username: ${{ secrets.NOTARIZATION_USERNAME }}
appstore-connect-password: ${{ secrets.NOTARIZATION_PASSWORD }}
appstore-connect-team-id: ${{ secrets.APPLE_TEAM_ID }}
- name: Prepare binary (Unix)
if: ${{ !startsWith(matrix.runner, 'windows') }}
run: |
cp target/${{ matrix.target }}/release/gnd ${{ matrix.asset_name }}
chmod +x ${{ matrix.asset_name }}
gzip ${{ matrix.asset_name }}
- name: Prepare binary (Windows)
if: startsWith(matrix.runner, 'windows')
run: |
copy target\${{ matrix.target }}\release\gnd.exe ${{ matrix.asset_name }}
7z a -tzip ${{ matrix.asset_name }}.zip ${{ matrix.asset_name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: |
${{ matrix.asset_name }}.gz
${{ matrix.asset_name }}.zip
if-no-files-found: error
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup GitHub CLI
run: |
# GitHub CLI is pre-installed on GitHub-hosted runners
gh --version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded artifacts
run: ls -R artifacts
- name: Upload Assets to Release
run: |
# Extract version from ref (remove refs/tags/ prefix)
VERSION=${GITHUB_REF#refs/tags/}
# Upload Linux x86_64 asset
gh release upload $VERSION artifacts/gnd-linux-x86_64/gnd-linux-x86_64.gz --repo $GITHUB_REPOSITORY
# Upload Linux ARM64 asset
gh release upload $VERSION artifacts/gnd-linux-aarch64/gnd-linux-aarch64.gz --repo $GITHUB_REPOSITORY
# Upload macOS x86_64 asset
gh release upload $VERSION artifacts/gnd-macos-x86_64/gnd-macos-x86_64.gz --repo $GITHUB_REPOSITORY
# Upload macOS ARM64 asset
gh release upload $VERSION artifacts/gnd-macos-aarch64/gnd-macos-aarch64.gz --repo $GITHUB_REPOSITORY
# Upload Windows x86_64 asset
gh release upload $VERSION artifacts/gnd-windows-x86_64.exe/gnd-windows-x86_64.exe.zip --repo $GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}