-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (96 loc) · 2.98 KB
/
Copy pathrelease.yml
File metadata and controls
117 lines (96 loc) · 2.98 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Release
on:
release:
types: [created]
workflow_dispatch: # Permet de déclencher manuellement pour tester
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
BIN_NAME: rpass
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive_ext: tar.gz
cross: true
- target: x86_64-apple-darwin
os: macos-latest
archive_ext: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive_ext: tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: rpass-release-${{ matrix.target }}
- name: Install cross (for aarch64 Linux)
if: matrix.cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build release binary (native)
if: '!matrix.cross'
run: cargo build --release --all-features --target ${{ matrix.target }}
- name: Build release binary (cross)
if: matrix.cross
run: cross build --release --all-features --target ${{ matrix.target }}
- name: Package binary
shell: bash
run: |
set -euo pipefail
STAGING="${BIN_NAME}-${{ matrix.target }}"
mkdir -p "$STAGING"
cp "target/${{ matrix.target }}/release/${BIN_NAME}" "$STAGING/"
cp README.md "$STAGING/" 2>/dev/null || true
cp LICENSE* "$STAGING/" 2>/dev/null || true
tar -czf "${STAGING}.tar.gz" "$STAGING"
echo "ASSET=${STAGING}.tar.gz" >> "$GITHUB_ENV"
- name: Smoke test binary
if: '!matrix.cross'
shell: bash
run: |
set -euo pipefail
BIN="target/${{ matrix.target }}/release/${BIN_NAME}"
"$BIN" --version
"$BIN" --help
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET }}
path: ${{ env.ASSET }}
publish:
name: Attach binaries to release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifacts
run: |
mkdir -p dist
find artifacts -type f -name "*.tar.gz" -exec cp {} dist/ \;
ls -la dist
- name: Upload to release
uses: softprops/action-gh-release@v2
with:
files: dist/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}