-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (85 loc) · 2.99 KB
/
Copy pathrelease.yml
File metadata and controls
97 lines (85 loc) · 2.99 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
name: Release cross-compile
on:
release:
types: [published]
jobs:
build-and-upload:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- i686-unknown-linux-musl
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install target and build deps
run: |
sudo apt-get update
sudo apt-get install -y \
musl-tools \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf \
gcc-i686-linux-gnu
rustup target add ${{ matrix.target }}
mkdir -p ~/.cargo
case "${{ matrix.target }}" in
i686-unknown-linux-musl)
echo '[target.i686-unknown-linux-musl]' >> ~/.cargo/config.toml
echo 'linker = "i686-linux-gnu-gcc"' >> ~/.cargo/config.toml
;;
aarch64-unknown-linux-musl)
echo '[target.aarch64-unknown-linux-musl]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
;;
armv7-unknown-linux-musleabihf)
echo '[target.armv7-unknown-linux-musleabihf]' >> ~/.cargo/config.toml
echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config.toml
;;
esac
- name: Cache cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.target }}
- name: Build (release)
env:
RUSTFLAGS: "-C target-feature=+crt-static -C link-arg=-s"
run: |
cargo build --release --target ${{ matrix.target }}
- name: Prepare artifact name
id: artifact
run: |
BIN_NAME=envex
VERSION=${{ github.ref_name }}
TARGET=${{ matrix.target }}
RELEASE_NAME="${BIN_NAME}-${VERSION}-${TARGET}"
OUT="target/${TARGET}/release/${BIN_NAME}"
if [ -f "${OUT}" ]; then
mkdir -p "${RELEASE_NAME}"
cp "${OUT}" "${RELEASE_NAME}/"
cp README.md LICENSE "${RELEASE_NAME}/"
cp -r man completions "${RELEASE_NAME}/"
tar czf "${RELEASE_NAME}.tar.gz" "${RELEASE_NAME}"
echo "found=true" >> $GITHUB_OUTPUT
echo "path=${RELEASE_NAME}.tar.gz" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: Upload release asset
if: steps.artifact.outputs.found == 'true'
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.artifact.outputs.path }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}