-
Notifications
You must be signed in to change notification settings - Fork 2
168 lines (147 loc) · 5.18 KB
/
release.yml
File metadata and controls
168 lines (147 loc) · 5.18 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
update_homebrew:
description: 'Update Homebrew formula after build'
required: false
default: 'false'
type: choice
options: ['true','false']
release_tag:
description: 'Release tag to upload artifacts to (e.g. v1.2.3)'
required: false
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
environment: packaging
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 (glibc)
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
artifact_name: bssh
asset_name: bssh-linux-x86_64
archive_ext: ".tar.gz"
protoc_platform: linux-x86_64
# Linux x86_64 (musl - static)
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
artifact_name: bssh
asset_name: bssh-linux-x86_64-musl
archive_ext: ".tar.gz"
protoc_platform: linux-x86_64
# Linux ARM64 (glibc)
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
artifact_name: bssh
asset_name: bssh-linux-aarch64
archive_ext: ".tar.gz"
protoc_platform: linux-aarch_64
# Linux ARM64 (musl - static)
- target: aarch64-unknown-linux-musl
os: ubuntu-24.04-arm
artifact_name: bssh
asset_name: bssh-linux-aarch64-musl
archive_ext: ".tar.gz"
protoc_platform: linux-aarch_64
# macOS ARM64
- target: aarch64-apple-darwin
os: macos-14
artifact_name: bssh
asset_name: bssh-macos-aarch64
archive_ext: ".zip"
protoc_platform: osx-aarch_64
env:
BIN_NAME: bssh
BUNDLE_ID: ${{ vars.BUNDLE_ID }}
steps:
# 1) Checkout repository
- name: Checkout code
uses: actions/checkout@v4
# 2) Cache Cargo build artifacts
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}-
# 3) Install Rust toolchain
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
# 4) Add target architecture
- name: Add target architecture
run: rustup target add ${{ matrix.target }}
# 5) Install musl tools only for aarch64 musl builds
- name: Install ARM64 musl tools (Linux aarch64 musl only)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt update
sudo apt install -y musl-tools
# 6) Build the release binary
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --locked
# 7) macOS code signing
- name: Import Distribution certificate
if: runner.os == 'macOS'
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.DEV_ID_CERT_P12 }}
p12-password: ${{ secrets.DEV_ID_CERT_PASSWORD }}
- name: Code sign macOS binary
if: runner.os == 'macOS'
run: |
BIN=target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
codesign --force --timestamp --options runtime \
--sign "Distribution" "$BIN"
# 8) Package binaries
- name: Package Linux binary (tar.gz)
if: runner.os == 'Linux'
run: |
BIN_DIR=target/${{ matrix.target }}/release
mkdir -p package
cp "$BIN_DIR/${{ matrix.artifact_name }}" package/
cp docs/man/bssh.1 package/
tar -C package -czf ${{ matrix.asset_name }}.tar.gz .
- name: Package macOS binary (zip)
if: runner.os == 'macOS'
run: |
BIN="target/${{ matrix.target }}/release/${{ matrix.artifact_name }}"
ASSET="${{ matrix.asset_name }}.zip"
mkdir -p package
cp "$BIN" package/
cp docs/man/bssh.1 package/
ditto -c -k --sequesterRsrc package "$ASSET"
# 9) Generate checksum
- name: Generate checksum
run: |
FILE="${{ matrix.asset_name }}${{ matrix.archive_ext }}"
if [[ "$RUNNER_OS" == "Linux" ]]; then
sha256sum "$FILE" > "$FILE.sha256"
else
shasum -a 256 "$FILE" > "$FILE.sha256"
fi
# 11) Upload release artifacts and checksum
- name: Upload release artifacts
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name || github.event.inputs.release_tag }}
files: |
${{ matrix.asset_name }}${{ matrix.archive_ext }}
${{ matrix.asset_name }}${{ matrix.archive_ext }}.sha256