-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (122 loc) · 4.04 KB
/
get-ctr.rs.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
name: build crate (get-ctr)
# auto-task.start-build-time = ?
on:
push:
branches: ["dev"]
paths:
- .github/workflows/get-ctr.rs.yml
- assets/build-get-ctr/Dockerfile
- Cargo.toml
- Cargo.lock
- "crates/get-ctr/src/**/*"
- crates/get-ctr/Cargo.toml
jobs:
docker:
strategy:
fail-fast: false
matrix:
include:
- arch: x64
target: x86_64-unknown-linux-gnu
platform: linux/amd64
machine: ubuntu-latest
- arch: arm64
target: aarch64-unknown-linux-musl
platform: linux/arm64
machine: ubuntu-latest
# - arch: rv64gc
# target: riscv64gc-unknown-linux-gnu
# platform: linux/riscv64
# machine: armbian
runs-on: ${{matrix.machine}}
defaults:
run:
shell: zsh --pipefail -fex {0}
env:
PROFILE: no-lto
CARGO_TARGET_DIR: /tmp/rs
PKG: get-ctr
steps:
- name: install zsh
if: (matrix.machine != 'armbian')
shell: sh -e {0}
run: ${{ vars.INSTALL_ZSH }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
# if: (!contains(fromJSON('["x64", "rv64gc"]'), matrix.arch))
if: (matrix.machine != 'armbian') || (matrix.arch != 'x64')
uses: docker/setup-qemu-action@v3
- uses: actions/checkout@v4
with:
ref: dev
- uses: actions/cache@v4
if: runner.arch == 'X64'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
${{env.CARGO_TARGET_DIR}}
key: ${{ runner.os }}-${{matrix.arch}}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: rustup update
id: rustup_update
continue-on-error: true
run: rustup update --force
- uses: dtolnay/rust-toolchain@stable
if: steps.rustup_update.outcome == 'failure'
- name: install cross-rs
if: runner.arch == 'X64'
run: ${{vars.INSTALL_CROSS}}
- name: cross build
if: runner.arch == 'X64'
run: cross build --target=${{matrix.target}} --package ${{env.PKG}} --profile ${{env.PROFILE}}
- name: set bin path
id: bin_path
run: print -R "bin=${{env.CARGO_TARGET_DIR}}/${{matrix.target}}/${{env.PROFILE}}/${{env.PKG}}" >> $GITHUB_OUTPUT
- name: scp tar to rv64sbc
id: scp_tar
if: matrix.arch == 'rv64gc'
env:
target_bin: ${{steps.bin_path.outputs.bin}}
run: |
file=$(mktemp).tar.zst
tar --use-compress-program='zstdmt -9v' -cf $file .
scp $file rv64:/tmp
print -R "file=$file" >> $GITHUB_OUTPUT
unlink $file
mkdir -pv ${target_bin:h}
- name: cargo build (riscv64imafdc)
if: matrix.arch == 'rv64gc'
uses: 2moe/local-ssh-action@v0
with:
host: rv64
run: |
typeset -x PROFILE=${{env.PROFILE}}
typeset -x CARGO_TARGET_DIR=${{env.CARGO_TARGET_DIR}}
dir=$(mktemp -d)
file=${{steps.scp_tar.outputs.file}}
tar -C $dir -xf $file
unlink $file
cd $dir || exit 1
cargo build --target=${{matrix.target}} --package get-ctr --profile ${{env.PROFILE}}
target_bin=${{steps.bin_path.outputs.bin}}
scp -C $target_bin armbian:$target_bin
rm -rfv $dir
- uses: actions/checkout@v4
with:
ref: build
- name: copy bin to docker context
run: install -Dm755 ${{steps.bin_path.outputs.bin}} assets/build-get-ctr/tmp.get-ctr
- name: Build and push
uses: docker/build-push-action@v5
with:
context: assets/build-get-ctr
push: true
tags: ghcr.io/2cd/pkgs:get-ctr-${{matrix.arch}}
platforms: ${{matrix.platform}}