-
Notifications
You must be signed in to change notification settings - Fork 7
162 lines (140 loc) · 4.72 KB
/
release.yaml
File metadata and controls
162 lines (140 loc) · 4.72 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
---
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
steps:
- name: Set up git repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Configure cross-compilation
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
mkdir -p .cargo
cat >> .cargo/config.toml <<EOF
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- name: Cache cargo registry and build
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('Cargo.lock', 'Cargo.toml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-release-
- name: Build release binaries
run: cargo build --release --target ${{ matrix.target }} --workspace
- name: Package binaries
shell: bash
run: |
TAG="${GITHUB_REF#refs/tags/}"
BINS=("ares")
for bin in "${BINS[@]}"; do
ARCHIVE="${bin}-${TAG}-${{ matrix.target }}"
mkdir -p "${ARCHIVE}"
cp "target/${{ matrix.target }}/release/${bin}" "${ARCHIVE}/" 2>/dev/null || true
if [ -f "${ARCHIVE}/${bin}" ]; then
tar czf "${ARCHIVE}.tar.gz" "${ARCHIVE}"
sha256sum "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256" || shasum -a 256 "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256"
fi
rm -rf "${ARCHIVE}"
done
- name: Upload artifacts
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: binaries-${{ matrix.target }}
path: |
*.tar.gz
*.tar.gz.sha256
retention-days: 1
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts
merge-multiple: true
- name: Generate checksums
id: checksums
working-directory: artifacts
run: |
cat ./*.sha256 | sort > checksums.txt
{
echo "checksums<<EOF"
cat checksums.txt
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Generate changelog
id: changelog
run: |
# Get previous tag
PREV_TAG=$(git tag --sort=-v:refname | head -2 | tail -1)
TAG="${GITHUB_REF#refs/tags/}"
if [ -n "${PREV_TAG}" ] && [ "${PREV_TAG}" != "${TAG}" ]; then
CHANGELOG=$(git log "${PREV_TAG}..${TAG}" --pretty=format:"- %s (%h)" --no-merges)
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
fi
{
echo "changelog<<EOF"
echo "${CHANGELOG}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
generate_release_notes: true
body: |
## Changes
${{ steps.changelog.outputs.changelog }}
## Checksums
```
${{ steps.checksums.outputs.checksums }}
```
files: |
artifacts/*.tar.gz
artifacts/*.tar.gz.sha256
artifacts/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}