-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (108 loc) · 3.39 KB
/
release.yml
File metadata and controls
125 lines (108 loc) · 3.39 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
name: CI and Release
on:
pull_request:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --workspace --all-targets
build-release:
name: Build ${{ matrix.target }}
if: startsWith(github.ref, 'refs/tags/v')
needs: checks
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
use_cross: false
- runner: macos-latest
target: x86_64-apple-darwin
use_cross: false
- runner: macos-14
target: aarch64-apple-darwin
use_cross: false
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install cross
if: matrix.use_cross
run: cargo install cross --version 0.2.5
- name: Build fishnet
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
cross build --release -p fishnet-cli --target ${{ matrix.target }}
else
cargo build --release -p fishnet-cli --target ${{ matrix.target }}
fi
- name: Package artifact
shell: bash
run: |
set -euo pipefail
mkdir -p dist
binary="target/${{ matrix.target }}/release/fishnet"
archive="fishnet-${{ matrix.target }}.tar.gz"
tar -czf "dist/${archive}" -C "$(dirname "${binary}")" "$(basename "${binary}")"
if command -v sha256sum >/dev/null 2>&1; then
(cd dist && sha256sum "${archive}" > "${archive}.sha256")
else
(cd dist && shasum -a 256 "${archive}" > "${archive}.sha256")
fi
- name: Upload artifact bundle
uses: actions/upload-artifact@v4
with:
name: fishnet-${{ matrix.target }}
path: dist/*
publish-release:
name: Publish GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
needs: build-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten artifacts
run: |
set -euo pipefail
mkdir -p release-assets
find dist -type f -name "fishnet-*.tar.gz" -exec cp {} release-assets/ \;
find dist -type f -name "fishnet-*.tar.gz.sha256" -exec cp {} release-assets/ \;
cp scripts/install.sh release-assets/install.sh
chmod +x release-assets/install.sh
cat release-assets/*.sha256 > release-assets/SHA256SUMS.txt
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
release-assets/fishnet-*.tar.gz
release-assets/fishnet-*.tar.gz.sha256
release-assets/SHA256SUMS.txt
release-assets/install.sh