-
Notifications
You must be signed in to change notification settings - Fork 5
85 lines (78 loc) · 2.64 KB
/
package_and_release.yaml
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
on:
workflow_call:
name: "[reusable] package and release"
jobs:
build:
name: Rust project
runs-on: ${{ matrix.os }}
env:
# For some builds, we use cross to test on 32-bit and big-endian
# systems.
CARGO: cargo
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
TARGET_FLAGS: ""
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
include:
- os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-gnu
- os: ubuntu-22.04
rust: stable
target: aarch64-unknown-linux-gnu
- os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-musl
- os: ubuntu-22.04
rust: stable
target: aarch64-unknown-linux-musl
- os: macos-12
rust: stable
target: x86_64-apple-darwin
- os: macos-12
rust: stable
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Use Cross
shell: bash
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
- name: Get latest tag
if: github.event_name == 'release'
id: get-latest-tag
run: |
echo LATEST_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1)) >> $GITHUB_ENV
- name: Package
if: github.event_name == 'release'
run: |
make bundle_release TARGET=${{ matrix.target }}
- uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
name: Upload release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.target}}/release/kubesess_${{ matrix.target }}.tar.gz
asset_name: kubesess_${{ env.LATEST_TAG }}_${{ matrix.target }}.tar.gz
tag: ${{ env.LATEST_TAG }}