-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (114 loc) · 3.84 KB
/
Copy pathrelease.yml
File metadata and controls
135 lines (114 loc) · 3.84 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: Release
on:
release:
types: [created]
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g., v0.1.0)'
required: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 (static with musl)
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
suffix: linux-x86_64
ext: ""
# Linux ARM64 (static with musl)
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
suffix: linux-arm64
ext: ""
# macOS x86_64
- os: macos-latest
target: x86_64-apple-darwin
suffix: macos-x86_64
ext: ""
# macOS ARM64 (Apple Silicon)
- os: macos-latest
target: aarch64-apple-darwin
suffix: macos-arm64
ext: ""
# Windows x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: windows-x86_64
ext: ".exe"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools (Linux x86_64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Install cross (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build (native)
if: matrix.target != 'aarch64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.target == 'aarch64-unknown-linux-musl'
run: cross build --release --target ${{ matrix.target }}
- name: Prepare artifacts (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/server dist/rust_chat_server-${{ matrix.suffix }}${{ matrix.ext }}
cp target/${{ matrix.target }}/release/client dist/rust_chat_client-${{ matrix.suffix }}${{ matrix.ext }}
chmod +x dist/*
- name: Prepare artifacts (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target/${{ matrix.target }}/release/server.exe" "dist/rust_chat_server-${{ matrix.suffix }}.exe"
Copy-Item "target/${{ matrix.target }}/release/client.exe" "dist/rust_chat_client-${{ matrix.suffix }}.exe"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.suffix }}
path: dist/*
retention-days: 1
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: binaries-*
merge-multiple: true
- name: Create checksums
run: |
cd artifacts
sha256sum * > checksums-sha256.txt
- name: Get release tag
id: tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
fi
- name: Upload to Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: artifacts/*
fail_on_unmatched_files: true