-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (72 loc) · 2.42 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
name: release
on:
push:
tags:
- v[0-9]+.*
jobs:
build:
name: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
use-cross: true
- target: aarch64-unknown-linux-musl
use-cross: true
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
use-cross: true
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
profile: minimal # minimal component installation (ie, no documentation)
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: --locked --release --target=${{ matrix.target }}
- name: Create tarball
id: package
shell: bash
run: |
PROJECT_BINARY=$(sed -n '/\[bin]/,$p' Cargo.toml | sed -n 's/^name = "\(.*\)"/\1/p' | head -n1)
PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
PKG_STAGING=$(mktemp -d)
PKG_BASENAME="${PROJECT_BINARY}-v${PROJECT_VERSION}-${{ matrix.target }}"
PKG_NAME="${PKG_BASENAME}.tar.gz"
ARCHIVE_DIR="$PKG_STAGING/$PKG_BASENAME/"
mkdir -p "$ARCHIVE_DIR"
# Binary
cp "target/${{ matrix.target }}/release/$PROJECT_BINARY" "$ARCHIVE_DIR"
# README, LICENSE and CHANGELOG files
cp "README.md" "UNLICENSE" "$ARCHIVE_DIR"
# include scripts dir
tar -cf - scripts | tar -C "$ARCHIVE_DIR" -xf -
# base compressed package
tar -C "$ARCHIVE_DIR" -czf "$PKG_STAGING/$PKG_NAME" .
# Let subsequent steps know where to find the compressed package
echo "PKG_NAME=$PKG_NAME" >> $GITHUB_ENV
echo "PKG_PATH=$PKG_STAGING/$PKG_NAME" >> $GITHUB_ENV
- uses: actions/upload-artifact@v3
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_PATH }}
- uses: softprops/action-gh-release@v1
with:
files: |
${{ env.PKG_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}