-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (123 loc) · 4.67 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (123 loc) · 4.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
135
136
137
138
139
140
141
142
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Pre-release Quality Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test
build:
name: Build and Release
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
suffix: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: ".exe"
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
- os: macos-latest
target: aarch64-apple-darwin
suffix: ""
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package binary
shell: bash
run: |
binary_name="file-dedup${{ matrix.suffix }}"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp "target/${{ matrix.target }}/release/${binary_name}" "${binary_name}"
else
cp "target/${{ matrix.target }}/release/file-dedup" "${binary_name}"
fi
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
7z a "file-dedup-${{ matrix.target }}.zip" "${binary_name}"
else
tar czf "file-dedup-${{ matrix.target }}.tar.gz" "${binary_name}"
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: file-dedup-${{ matrix.target }}
path: file-dedup-${{ matrix.target }}.*
release:
name: Create Release
needs: [check, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Generate release notes
id: release_notes
run: |
tag_name=${GITHUB_REF#refs/tags/}
prev_tag=$(git describe --tags --abbrev=0 ${tag_name}^ 2>/dev/null || echo "")
echo "# Release ${tag_name}" > release_notes.md
echo "" >> release_notes.md
if [[ -n "$prev_tag" ]]; then
echo "## Changes since ${prev_tag}" >> release_notes.md
echo "" >> release_notes.md
git log --pretty=format:"- %s" ${prev_tag}..${tag_name} >> release_notes.md
else
echo "## Changes" >> release_notes.md
echo "" >> release_notes.md
git log --pretty=format:"- %s" ${tag_name} >> release_notes.md
fi
echo "" >> release_notes.md
echo "## Binaries" >> release_notes.md
echo "" >> release_notes.md
echo "Download the appropriate binary for your platform:" >> release_notes.md
echo "" >> release_notes.md
echo "- **Linux x86_64**: \`file-dedup-x86_64-unknown-linux-gnu.tar.gz\`" >> release_notes.md
echo "- **Linux x86_64 (musl)**: \`file-dedup-x86_64-unknown-linux-musl.tar.gz\`" >> release_notes.md
echo "- **Windows x86_64**: \`file-dedup-x86_64-pc-windows-msvc.zip\`" >> release_notes.md
echo "- **macOS x86_64 (Intel)**: \`file-dedup-x86_64-apple-darwin.tar.gz\`" >> release_notes.md
echo "- **macOS ARM64 (Apple Silicon)**: \`file-dedup-aarch64-apple-darwin.tar.gz\`" >> release_notes.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: release_notes.md
files: |
file-dedup-x86_64-unknown-linux-gnu/file-dedup-x86_64-unknown-linux-gnu.tar.gz
file-dedup-x86_64-unknown-linux-musl/file-dedup-x86_64-unknown-linux-musl.tar.gz
file-dedup-x86_64-pc-windows-msvc/file-dedup-x86_64-pc-windows-msvc.zip
file-dedup-x86_64-apple-darwin/file-dedup-x86_64-apple-darwin.tar.gz
file-dedup-aarch64-apple-darwin/file-dedup-aarch64-apple-darwin.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}