-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (115 loc) · 3.67 KB
/
release.yml
File metadata and controls
134 lines (115 loc) · 3.67 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Output version
run: |
echo "Release version: ${{ steps.get_version.outputs.version }}"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
draft: false
prerelease: false
generate_release_notes: true
name: Release v${{ steps.get_version.outputs.version }}
build-release:
name: Build (${{ matrix.target }})
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
use-cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
use-cross: true
- target: x86_64-apple-darwin
os: macos-latest
use-cross: false
- target: aarch64-apple-darwin
os: macos-latest
use-cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
use-cross: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross (if needed)
if: matrix.use-cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build binary
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Prepare release asset
id: prepare
shell: bash
run: |
VERSION="${{ needs.create-release.outputs.version }}"
TARGET="${{ matrix.target }}"
# Set binary name based on OS
if [[ "$TARGET" == *"windows"* ]]; then
BINARY="ppap.exe"
ARCHIVE="ppap-${VERSION}-${TARGET}.zip"
cd target/${TARGET}/release
7z a "../../../${ARCHIVE}" "${BINARY}"
cd ../../..
else
BINARY="ppap"
ARCHIVE="ppap-${VERSION}-${TARGET}.tar.gz"
cd target/${TARGET}/release
tar -czf "../../../${ARCHIVE}" "${BINARY}"
cd ../../..
fi
# Generate checksum
if [[ "$RUNNER_OS" == "Windows" ]]; then
certutil -hashfile "${ARCHIVE}" SHA256 > "${ARCHIVE}.sha256"
else
shasum -a 256 "${ARCHIVE}" > "${ARCHIVE}.sha256"
fi
echo "archive=${ARCHIVE}" >> $GITHUB_OUTPUT
echo "checksum=${ARCHIVE}.sha256" >> $GITHUB_OUTPUT
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.create-release.outputs.version }}
files: |
${{ steps.prepare.outputs.archive }}
${{ steps.prepare.outputs.checksum }}