Skip to content

Commit 45d9e47

Browse files
authored
Create build-and-release.yml
1 parent c0bec22 commit 45d9e47

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
tags:
7+
- "v*"
8+
pull_request:
9+
workflow_dispatch:
10+
11+
env:
12+
PROJECT_NAME: 6cy
13+
RUST_TOOLCHAIN: stable
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
include:
21+
- os: ubuntu-latest
22+
target: x86_64-unknown-linux-gnu
23+
- os: windows-latest
24+
target: x86_64-pc-windows-msvc
25+
- os: macos-latest
26+
target: x86_64-apple-darwin
27+
- os: macos-latest
28+
target: aarch64-apple-darwin
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: dtolnay/rust-toolchain@stable
34+
with:
35+
toolchain: ${{ env.RUST_TOOLCHAIN }}
36+
targets: ${{ matrix.target }}
37+
38+
- uses: actions/cache@v4
39+
with:
40+
path: |
41+
~/.cargo/registry
42+
~/.cargo/git
43+
target
44+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-cargo-
47+
48+
- if: runner.os == 'Linux'
49+
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev || true
50+
51+
- run: cargo build --release --target ${{ matrix.target }}
52+
53+
- name: Package Unix
54+
if: runner.os != 'Windows'
55+
run: |
56+
set -e
57+
BIN=${{ env.PROJECT_NAME }}
58+
TARGET_DIR=target/${{ matrix.target }}/release
59+
mkdir -p dist
60+
cp "${TARGET_DIR}/${BIN}" .
61+
TAR_NAME="${BIN}-${{ matrix.target }}.tar.gz"
62+
tar -czf "dist/${TAR_NAME}" "${BIN}"
63+
sha256sum "dist/${TAR_NAME}" | awk '{print $1}' > "dist/${TAR_NAME}.sha256"
64+
shell: bash
65+
66+
- name: Package Windows
67+
if: runner.os == 'Windows'
68+
run: |
69+
$bin = "${{ env.PROJECT_NAME }}.exe"
70+
$target = "target/${{ matrix.target }}/release"
71+
New-Item -ItemType Directory -Force -Path dist | Out-Null
72+
Copy-Item "$target/$bin" .
73+
$zipName = "dist/${{ env.PROJECT_NAME }}-${{ matrix.target }}.zip"
74+
Compress-Archive -Path $bin -DestinationPath $zipName
75+
(Get-FileHash $zipName -Algorithm SHA256).Hash | Out-File "$zipName.sha256" -Encoding ascii
76+
shell: pwsh
77+
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
name: ${{ env.PROJECT_NAME }}-${{ matrix.target }}
81+
path: dist/**

0 commit comments

Comments
 (0)