-
Notifications
You must be signed in to change notification settings - Fork 24
202 lines (188 loc) · 6.34 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
name: Build + draft release
on:
workflow_dispatch:
inputs:
version:
description: 'The type of version bump. Use "nobump" for no change.'
type: choice
required: true
default: nobump
options:
- major
- minor
- patch
- nobump
jobs:
prepare:
if: github.repository_owner == 'viamrobotics'
runs-on: [buildjet-2vcpu-ubuntu-2204-arm]
outputs:
version: ${{ steps.which_version.outputs.version }}
sha: ${{ steps.commit.outputs.commit_long_sha }}
steps:
- name: Check if organization member
id: is_organization_member
uses: jamessingleton/[email protected]
with:
organization: viamrobotics
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Cancelling - user not part of organization
uses: andymckay/[email protected]
if: |
steps.is_organization_member.outputs.result == 'false'
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Bump Version
shell: bash
if: inputs.version != 'nobump'
run: |
cargo install cargo-release
cargo release version ${{ inputs.version }} --execute --no-confirm
- name: Which Version
id: which_version
shell: bash
run: |
cargo update
echo "version=$(cargo pkgid | sed 's/.*@//g')" >> $GITHUB_OUTPUT
- name: Check if release exists
uses: cardinalby/[email protected]
id: release_exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseName: v${{ steps.which_version.outputs.version }}
doNotFailIfNotFound: 'true'
- name: Cancelling - release already exists
uses: andymckay/[email protected]
if: steps.release_exists.outputs.id != ''
- name: Commit + Push
id: commit
uses: EndBug/[email protected]
with:
default_author: github_actions
message: Bumping version to v${{ steps.which_version.outputs.version }} [skip ci]
build_macos:
if: github.repository_owner == 'viamrobotics'
needs: [prepare]
runs-on: [self-hosted, ARM64, macOS]
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
platform: macosx_arm64
- target: x86_64-apple-darwin
platform: macosx_x86_64
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ needs.prepare.outputs.sha }}
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Setup build directory
run: mkdir builds
- name: Build
run: |
cargo build --release --target=${{ matrix.target }}
- name: Copy
run: |
cp target/${{ matrix.target }}/release/libviam_rust_utils.dylib builds/libviam_rust_utils-${{ matrix.platform }}.dylib
cp target/${{ matrix.target }}/release/libviam_rust_utils.a builds/libviam_rust_utils-${{ matrix.platform }}.a
- name: Correct install path
run: |
install_name_tool -id "@rpath/libviam_rust_utils.dylib" builds/libviam_rust_utils-${{ matrix.platform }}.dylib
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: builds
path: builds
build_linux:
if: github.repository_owner == 'viamrobotics'
needs: [prepare]
runs-on: ${{ matrix.runs-on }}
container:
image: ${{ matrix.image }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
platform: linux_aarch64
image: ubuntu:20.04
runs-on: buildjet-8vcpu-ubuntu-2204-arm
- target: x86_64-unknown-linux-gnu
platform: linux_x86_64
image: ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main-centos
runs-on: buildjet-2vcpu-ubuntu-2204
- target: arm-unknown-linux-gnueabihf
platform: linux_armv6l
image: ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main
runs-on: buildjet-2vcpu-ubuntu-2204
steps:
- name: Setup dependencies
if: ${{ startsWith(matrix.image, 'ubuntu') }}
shell: bash
run: | # (njooma) These are the deps that cross uses. I haven't tried pruning/optimizing
apt-get update && apt-get upgrade -y
apt-get install -y autoconf \
automake \
binutils \
ca-certificates \
curl \
file \
gcc \
git \
libtool \
m4 \
make
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ needs.prepare.outputs.sha }}
- name: Setup rust toolchain
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup target add ${{ matrix.target }}
- name: Setup build directory
run: mkdir builds
- name: Build
shell: bash
run: |
source "$HOME/.cargo/env"
cargo build --release --locked --target=${{ matrix.target }}
- name: Copy
run: |
cp target/${{ matrix.target }}/release/libviam_rust_utils.so builds/libviam_rust_utils-${{ matrix.platform }}.so
cp target/${{ matrix.target }}/release/libviam_rust_utils.a builds/libviam_rust_utils-${{ matrix.platform }}.a
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: builds
path: builds
release:
needs: [prepare, build_macos, build_linux]
if: github.repository_owner == 'viamrobotics'
runs-on: [self-hosted, x64]
container:
image: ghcr.io/viamrobotics/canon:amd64
steps:
- uses: actions/download-artifact@v3
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.prepare.outputs.version }}
files: builds/*
draft: true
prerelease: false
fail_on_unmatched_files: true