-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (185 loc) · 6.68 KB
/
release.yml
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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
id-token: write
contents: write
packages: write
jobs:
build-binaries:
name: Build Binaries
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
arch:
- x64
- arm64
exclude:
- platform: windows-latest
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Tools
uses: ./.github/actions/install-tools
- name: Set up MSVC Environment
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Remove Git link.exe from PATH
if: runner.os == 'Windows'
run: |
echo "Original PATH: %PATH%"
set PATH=%PATH:"C:\Program Files\Git\usr\bin";=%
echo "Modified PATH: %PATH%"
shell: cmd
- name: Check for Correct link.exe
if: runner.os == 'Windows'
run: where link
- name: Install Cross
if: runner.os != 'Windows'
run: cargo install cross --locked
- name: Build Binaries (Unix)
if: runner.os != 'Windows'
run: |
echo "Building for ${{ matrix.platform }} on architecture ${{ matrix.arch }}"
if [[ "${{ matrix.platform }}" == "ubuntu-latest" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cross build --release --target x86_64-unknown-linux-gnu
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
cross build --release --target aarch64-unknown-linux-gnu
fi
elif [[ "${{ matrix.platform }}" == "macos-latest" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cross build --release --target x86_64-apple-darwin
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
cross build --release --target aarch64-apple-darwin
fi
fi
shell: bash
- name: Build Binaries (Windows)
if: runner.os == 'Windows'
run: |
echo "Building for ${{ matrix.platform }} on architecture ${{ matrix.arch }}"
cargo build --release --target x86_64-pc-windows-msvc
shell: cmd
- name: Move Binaries to Bin Folder (Unix)
if: runner.os != 'Windows'
run: |
if [[ "${{ matrix.platform }}" == "ubuntu-latest" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
mkdir -p ./packages/linux-x64
cp target/x86_64-unknown-linux-gnu/release/todoctor ./packages/linux-x64/todoctor
chmod +x ./packages/linux-x64/todoctor
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
mkdir -p ./packages/linux-arm64
cp target/aarch64-unknown-linux-gnu/release/todoctor ./packages/linux-arm64/todoctor
chmod +x ./packages/linux-arm64/todoctor
fi
elif [[ "${{ matrix.platform }}" == "macos-latest" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
mkdir -p ./packages/darwin-x64
cp target/x86_64-apple-darwin/release/todoctor ./packages/darwin-x64/todoctor
chmod +x ./packages/darwin-x64/todoctor
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
mkdir -p ./packages/darwin-arm64
cp target/aarch64-apple-darwin/release/todoctor ./packages/darwin-arm64/todoctor
chmod +x ./packages/darwin-arm64/todoctor
fi
fi
shell: bash
- name: Move Binaries to Bin Folder (Windows)
if: runner.os == 'Windows'
run: |
mkdir packages\win32-x64
copy target\x86_64-pc-windows-msvc\release\todoctor.exe packages\win32-x64\todoctor.exe
shell: cmd
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: todoctor-${{ matrix.platform }}-${{ matrix.arch }}
path: '**/*'
release:
name: Release
runs-on: ubuntu-latest
needs: build-binaries
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Tools
uses: ./.github/actions/install-tools
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Build Static Assets
run: pnpm run build:preview
- name: Download Binaries for Linux x64
uses: actions/download-artifact@v4
with:
name: todoctor-ubuntu-latest-x64
path: .
- name: Download Binaries for Linux arm64
uses: actions/download-artifact@v4
with:
name: todoctor-ubuntu-latest-arm64
path: .
- name: Download Binaries for macOS x64
uses: actions/download-artifact@v4
with:
name: todoctor-macos-latest-x64
path: .
- name: Download Binaries for macOS arm64
uses: actions/download-artifact@v4
with:
name: todoctor-macos-latest-arm64
path: .
- name: Download Binaries for Windows x64
uses: actions/download-artifact@v4
with:
name: todoctor-windows-latest-x64
path: .
- name: Set Execute Permissions on Binaries
run: |
chmod +x ./packages/linux-x64/todoctor
chmod +x ./packages/linux-arm64/todoctor
chmod +x ./packages/darwin-x64/todoctor
chmod +x ./packages/darwin-arm64/todoctor
- name: Verify Binary Permissions
run: |
ls -l ./packages/linux-x64/todoctor
ls -l ./packages/linux-arm64/todoctor
ls -l ./packages/darwin-x64/todoctor
ls -l ./packages/darwin-arm64/todoctor
- name: Create GitHub Release
run: pnpm run ci:changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure NPM Auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" > ~/.npmrc
- name: Update Package Versions
shell: bash
run: node ./scripts/version.js
- name: Clear Package JSON
run: pnpm run ci:clear
- name: Publish Root Package to NPM
run: npm publish --access public --no-git-checks --provenance
- name: Publish Packages to NPM
run: |
for pkg in packages/*; do
if [ -d "$pkg" ]; then
echo "Publishing package $pkg"
cd "$pkg"
npm publish --access public --no-git-checks --provenance
cd -
fi
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}