-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (149 loc) · 5.09 KB
/
release.yml
File metadata and controls
180 lines (149 loc) · 5.09 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
quality-checks:
name: Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Setup Chrome configuration
run: |
# Check if Chrome exists in standard locations
if [ -f "/usr/bin/google-chrome" ]; then
CHROME_PATH="/usr/bin/google-chrome"
elif [ -f "/usr/bin/chromium-browser" ]; then
CHROME_PATH="/usr/bin/chromium-browser"
else
echo "ERROR: Chrome/Chromium not found"
exit 1
fi
echo "Found Chrome at: $CHROME_PATH"
$CHROME_PATH --version
# Create config directory and set browser path
mkdir -p ~/.config/google-patent-cli
cat > ~/.config/google-patent-cli/config.toml << EOF
browser_path = "$CHROME_PATH"
EOF
echo "Config file created:"
cat ~/.config/google-patent-cli/config.toml
- name: Check formatting
run: cargo fmt -- --check
- name: Build and lint
run: cargo clippy --all-targets -- -D warnings
- name: Run tests
run: cargo test
- name: Check build
run: cargo check --release
build:
name: Build ${{ matrix.platform }}
needs: quality-checks
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux x86_64
- os: ubuntu-22.04
platform: linux-x86_64
target: x86_64-unknown-linux-gnu
binary_name: google-patent-cli
archive_name: google-patent-cli-linux-x86_64.tar.gz
# Linux ARM64
- os: ubuntu-22.04
platform: linux-arm64
target: aarch64-unknown-linux-gnu
binary_name: google-patent-cli
archive_name: google-patent-cli-linux-arm64.tar.gz
use_cross: true
# macOS x86_64
- os: macos-latest
platform: macos-x86_64
target: x86_64-apple-darwin
binary_name: google-patent-cli
archive_name: google-patent-cli-macos-x86_64.tar.gz
# macOS ARM64 (Apple Silicon)
- os: macos-latest
platform: macos-arm64
target: aarch64-apple-darwin
binary_name: google-patent-cli
archive_name: google-patent-cli-macos-arm64.tar.gz
# Windows x86_64
- os: windows-latest
platform: windows-x86_64
target: x86_64-pc-windows-msvc
binary_name: google-patent-cli.exe
archive_name: google-patent-cli-windows-x86_64.zip
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install cross
if: matrix.use_cross == true
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build release binary (Unix)
if: matrix.os != 'windows-latest'
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Build release binary (Windows)
if: matrix.os == 'windows-latest'
run: cargo build --release --target ${{ matrix.target }}
- name: Create archive (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czf ${{ matrix.archive_name }} ${{ matrix.binary_name }}
mv ${{ matrix.archive_name }} ${{ github.workspace }}/
- name: Create archive (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path ${{ matrix.binary_name }} -DestinationPath ${{ github.workspace }}/${{ matrix.archive_name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: ${{ matrix.archive_name }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
# Create release
gh release create "$VERSION" \
--title "Release $VERSION" \
--generate-notes \
artifacts/*/*.tar.gz \
artifacts/*/*.zip