-
Notifications
You must be signed in to change notification settings - Fork 3
126 lines (116 loc) · 3.37 KB
/
prepare-release.yml
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
---
name: Prepare release
on:
workflow_dispatch:
inputs:
version:
description: The tag to release
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
jobs:
build:
strategy:
matrix:
name:
- linux-x86-64-gnu
- linux-x86-64-musl
- linux-armv7-gnu
- linux-arm64-gnu
- mac-x86-64
- mac-arm64
- windows-x86-64
include:
- name: linux-x86-64-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross: false
- name: linux-x86-64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
cross: true
- name: linux-armv7-gnu
os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
cross: true
- name: linux-arm64-gnu
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross: true
- name: mac-x86-64
os: macos-latest
target: x86_64-apple-darwin
cross: false
- name: mac-arm64
os: macos-latest
target: aarch64-apple-darwin
cross: false
- name: windows-x86-64
os: windows-latest
target: x86_64-pc-windows-msvc
cross: false
name: Binaries for ${{ matrix.name }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Get build cache
uses: Swatinem/rust-cache@v2
- name: Build
shell: bash
run: |
if [[ "${{ matrix.cross }}" == "true" ]]; then
cross build --release --locked --target ${{ matrix.target }}
else
cargo build --release --locked --target ${{ matrix.target }}
fi
- name: Package
shell: bash
run: |
ext=""
[[ "${{ matrix.name }}" == windows-* ]] && ext=".exe"
bin="target/${{ matrix.target }}/release/aegis-rs${ext}"
version=$(echo "${{ github.ref }}" | cut -d/ -f3)
dst="aegis-${{ matrix.target }}-${version}"
mkdir "$dst"
mv "$bin" "$dst/"
cp README.md LICENSE "$dst/"
- name: Archive (tar)
if: '! startsWith(matrix.name, ''windows-'')'
shell: bash
run: |
version=$(echo "${{ github.ref }}" | cut -d/ -f3)
dst="aegis-${{ matrix.target }}-${version}"
tar cavf "$dst.tgz" "$dst"
- name: Archive (zip)
if: startsWith(matrix.name, 'windows-')
shell: bash
run: |
version=$(echo "${{ github.ref }}" | cut -d/ -f3)
dst="aegis-${{ matrix.target }}-${version}"
7z a "$dst.zip" "$dst"
- name: Create release draft
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
aegis-*.tgz
aegis-*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}