-
Notifications
You must be signed in to change notification settings - Fork 3
135 lines (115 loc) Β· 4.04 KB
/
release.yml
File metadata and controls
135 lines (115 loc) Β· 4.04 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: "Build and Release"
permissions:
contents: write
on:
push:
tags:
- "v*"
env:
BIN_NAME: ssh-list
jobs:
create-release:
name: Create Draft Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create GitHub Draft Release
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: true
prerelease: true
build-release:
name: Build and Upload Binaries
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: i686-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: i686-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: ${{ matrix.os == 'windows-latest' && '-C target-feature=+crt-static' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cross-compilation tools (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf musl-tools
- name: Configure cross-compilation linkers (Linux)
if: runner.os == 'Linux'
run: |
mkdir -p .cargo
cat > .cargo/config.toml <<EOF
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.i686-unknown-linux-musl]
linker = "musl-gcc"
EOF
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ runner.os }}-${{ matrix.target }}
- name: Run tests
if: "!contains(matrix.target, 'musl')"
run: cargo test --target ${{ matrix.target }} --verbose
- name: Build release binary
run: cargo build --target ${{ matrix.target }} --verbose --release
- name: Package Release Asset
id: package_asset
shell: bash
run: |
BINARY_NAME="${{ env.BIN_NAME }}"
VERSION="${{ github.ref_name }}"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
ARCHIVE_NAME="${BINARY_NAME}-${VERSION}-${{ matrix.target }}.zip"
powershell -Command "Compress-Archive -Path 'target/${{ matrix.target }}/release/${BINARY_NAME}.exe' -DestinationPath '${ARCHIVE_NAME}'"
else
ARCHIVE_NAME="${BINARY_NAME}-${VERSION}-${{ matrix.target }}.tar.gz"
tar -czf "${ARCHIVE_NAME}" -C "target/${{ matrix.target }}/release" "${BINARY_NAME}"
fi
echo "archive_path=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} ${{ steps.package_asset.outputs.archive_path }}
publish-release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: [create-release, build-release]
steps:
- name: Publish the release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
allowUpdates: true
draft: false
prerelease: false