-
Notifications
You must be signed in to change notification settings - Fork 2
236 lines (200 loc) · 8.14 KB
/
release.yml
File metadata and controls
236 lines (200 loc) · 8.14 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
packages: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release ${{ steps.get_version.outputs.VERSION }}
body: |
# DiffScope ${{ steps.get_version.outputs.VERSION }}
See [CHANGELOG.md](https://github.com/haasonsaas/diffscope/blob/main/CHANGELOG.md) for details.
## 🚀 Installation
### Quick install (Linux/macOS):
```bash
curl -sSL https://raw.githubusercontent.com/haasonsaas/diffscope/main/install.sh | sh
```
### Quick install (Windows):
```powershell
iwr -useb https://raw.githubusercontent.com/haasonsaas/diffscope/main/install.ps1 | iex
```
### Manual installation:
Download the appropriate binary below for your platform and add it to your PATH.
## 📦 Checksums
SHA256 checksums will be available once all builds complete.
draft: false
prerelease: false
generate_release_notes: true
build-release:
name: Build Release
needs: create-release
strategy:
matrix:
include:
# Linux
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: diffscope
asset_name: diffscope-x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: diffscope
asset_name: diffscope-x86_64-unknown-linux-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: diffscope
asset_name: diffscope-aarch64-unknown-linux-gnu
# macOS
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: diffscope
asset_name: diffscope-x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: diffscope
asset_name: diffscope-aarch64-apple-darwin
# Windows
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: diffscope.exe
asset_name: diffscope-x86_64-pc-windows-msvc.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@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
- name: Install musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Set up macOS cross-compilation
if: matrix.os == 'macos-latest' && matrix.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Strip binary (Linux and macOS)
if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin' && matrix.target != 'aarch64-unknown-linux-gnu'
run: |
strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Strip binary (macOS ARM64)
if: matrix.target == 'aarch64-apple-darwin'
run: |
# Skip stripping for cross-compiled ARM64 binary or use lipo if needed
echo "Skipping strip for cross-compiled ARM64 binary"
- name: Strip binary (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
# Use aarch64 strip for cross-compiled binary
aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Create checksum (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release/
if [ -f "${{ matrix.artifact_name }}" ]; then
if [[ "$RUNNER_OS" == "macOS" ]]; then
shasum -a 256 ${{ matrix.artifact_name }} > ${{ matrix.asset_name }}.sha256
else
sha256sum ${{ matrix.artifact_name }} > ${{ matrix.asset_name }}.sha256
fi
else
echo "Binary not found, build may have failed"
exit 1
fi
- name: Create checksum (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release/
(Get-FileHash -Algorithm SHA256 ${{ matrix.artifact_name }}).Hash + " " + "${{ matrix.artifact_name }}" | Out-File -Encoding ASCII ${{ matrix.asset_name }}.sha256
- name: Upload Release Asset (Unix)
if: matrix.os != 'windows-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd target/${{ matrix.target }}/release/
# Upload binary
if [ -f "${{ matrix.artifact_name }}" ]; then
echo "Uploading ${{ matrix.artifact_name }}..."
gh release upload ${{ github.ref_name }} "${{ matrix.artifact_name }}" --clobber || true
fi
# Upload checksum
if [ -f "${{ matrix.asset_name }}.sha256" ]; then
echo "Uploading ${{ matrix.asset_name }}.sha256..."
gh release upload ${{ github.ref_name }} "${{ matrix.asset_name }}.sha256" --clobber || true
fi
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd target/${{ matrix.target }}/release/
# Upload binary
if (Test-Path "${{ matrix.artifact_name }}") {
Write-Host "Uploading ${{ matrix.artifact_name }}..."
gh release upload ${{ github.ref_name }} "${{ matrix.artifact_name }}" --clobber
}
# Upload checksum
if (Test-Path "${{ matrix.asset_name }}.sha256") {
Write-Host "Uploading ${{ matrix.asset_name }}.sha256..."
gh release upload ${{ github.ref_name }} "${{ matrix.asset_name }}.sha256" --clobber
}
build-docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/haasonsaas/diffscope:latest
ghcr.io/haasonsaas/diffscope:${{ steps.get_version.outputs.VERSION }}
# Homebrew formula update can be added later when tap repository is created
# For now, users can use the install script or download binaries directly