forked from longbridge/gpui-component
-
Notifications
You must be signed in to change notification settings - Fork 11
191 lines (167 loc) · 6.04 KB
/
release.yml
File metadata and controls
191 lines (167 loc) · 6.04 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
binary: onetcli
archive: onetcli-aarch64-apple-darwin.tar.gz
- target: x86_64-apple-darwin
os: macos-15-intel
binary: onetcli
archive: onetcli-x86_64-apple-darwin.tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
binary: onetcli
archive: onetcli-x86_64-unknown-linux-gnu.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
binary: onetcli.exe
archive: onetcli-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: script/bootstrap
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: script/bootstrap
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake --version
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
build-${{ matrix.target }}-
- name: Set environment variables
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "ONETCLI_VERSION=${VERSION}" >> "$GITHUB_ENV"
else
echo "ONETCLI_VERSION=0.0.0-dev.$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
fi
- name: Verify secrets are set
shell: bash
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: |
if [ -z "$SUPABASE_URL" ]; then
echo "::error::SUPABASE_URL secret is empty or not set"
exit 1
fi
if [ -z "$SUPABASE_ANON_KEY" ]; then
echo "::error::SUPABASE_ANON_KEY secret is empty or not set"
exit 1
fi
- name: Build release binary
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
ONETCLI_UPDATE_URL: ${{ secrets.ONETCLI_UPDATE_URL }}
ONETCLI_UPDATE_DOWNLOAD_URL: ${{ secrets.ONETCLI_UPDATE_DOWNLOAD_URL }}
ONETCLI_WECHAT_QR_URL: ${{ secrets.ONETCLI_WECHAT_QR_URL }}
ONETCLI_ALIPAY_QR_URL: ${{ secrets.ONETCLI_ALIPAY_QR_URL }}
ONETCLI_PAYPAL_QR_URL: ${{ secrets.ONETCLI_PAYPAL_QR_URL }}
run: cargo build --release -p main --target ${{ matrix.target }}
- name: Create macOS app bundle
if: runner.os == 'macOS'
run: |
chmod +x script/bundle-macos.sh
chmod +x script/bundle-macos-dmg.sh
script/bundle-macos.sh ${{ matrix.target }}
script/bundle-macos-dmg.sh ${{ matrix.target }}
tar czf ${{ matrix.archive }} -C target OnetCli.app
- name: Package (Linux)
if: runner.os == 'Linux'
run: |
mkdir -p package/usr/bin
mkdir -p package/usr/share/applications
mkdir -p package/usr/share/icons/hicolor/128x128/apps
mkdir -p package/usr/share/icons/hicolor/256x256/apps
mkdir -p package/usr/share/icons/hicolor/512x512/apps
cp target/${{ matrix.target }}/release/${{ matrix.binary }} package/usr/bin/
cp resources/linux/onetcli.desktop package/usr/share/applications/
cp resources/linux/onetcli-128.png package/usr/share/icons/hicolor/128x128/apps/onetcli.png
cp resources/linux/onetcli-256.png package/usr/share/icons/hicolor/256x256/apps/onetcli.png
cp resources/linux/onetcli-512.png package/usr/share/icons/hicolor/512x512/apps/onetcli.png
tar czf ${{ matrix.archive }} -C package .
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive -Path "target/${{ matrix.target }}/release/${{ matrix.binary }}" -DestinationPath "${{ matrix.archive }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
- name: Upload macOS DMG artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: onetcli-${{ matrix.target }}.dmg
path: onetcli-${{ matrix.target }}.dmg
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Generate checksums
run: |
cd artifacts
sha256sum onetcli-* > sha256sums.txt
cat sha256sums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: OnetCli ${{ github.ref_name }}
generate_release_notes: true
files: |
artifacts/onetcli-*.tar.gz
artifacts/onetcli-*.zip
artifacts/onetcli-*.dmg
artifacts/sha256sums.txt