-
Notifications
You must be signed in to change notification settings - Fork 108
152 lines (139 loc) · 5.11 KB
/
ci.yml
File metadata and controls
152 lines (139 loc) · 5.11 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
name: CI
on:
push:
branches-ignore:
- 'dependabot/**'
tags:
- '**'
pull_request:
jobs:
build:
name: Build & test
strategy:
matrix:
include:
- platform: linux
arch: x64
os: "ubuntu-22.04"
- platform: linux
arch: arm64
os: "ubuntu-24.04-arm"
- platform: windows
arch: x64
os: "windows-2022"
- platform: mac
arch: x64
os: "macos-15-intel"
- platform: mac
arch: arm64
os: "macos-14"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.20.0
check-latest: true
cache: 'npm'
# Due to https://github.com/electron-userland/electron-builder/issues/3901
# Electron-Builder fails to produce deb packages on arm64 without this:
- name: Install system FPM to fix ARM64 Linux builds
if: matrix.platform == 'linux' && matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install ruby ruby-dev build-essential
sudo gem install --no-document fpm
- run: npm ci
# The API key in APPLE_API_KEY is a PEM cert that must be read from disk:
- name: Prepare Apple API key
run: echo "$APPLE_API_KEY" > ./apple-api-key.p8
if: github.event_name == 'push' && startsWith(matrix.os, 'macos-')
env:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
# On push we do signed builds, on PRs we do unsigned builds only (next step)
- name: Run signed build
if: github.event_name == 'push'
run: npm run build
env:
ENABLE_SIGNING: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# For Mac notarization:
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_KEY: ./apple-api-key.p8
# For Mac signing:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
# For Windows signing:
WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
# Workaround - see FPM install step above
USE_SYSTEM_FPM: ${{ matrix.platform == 'linux' && matrix.arch == 'arm64' }}
- name: Run unsigned build
if: github.event_name != 'push'
run: npm run build
env:
ENABLE_SIGNING: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USE_SYSTEM_FPM: ${{ matrix.platform == 'linux' && matrix.arch == 'arm64' }}
- name: Run smoke tests
run: |
# We manually start ADB, so the tests don't (because if they do, they fail
# to exit, due to the hanging process)
"$ANDROID_HOME/platform-tools/adb" start-server 2>/dev/null || true
if [ "$RUNNER_OS" == "Linux" ]; then
xvfb-run --auto-servernum npm test
else
npm test
fi
shell: bash
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.arch }}-distributables
path: dist/HttpToolkit-*
if-no-files-found: error
publish:
name: Publish a release
runs-on: "ubuntu-22.04"
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Get all distributables
uses: actions/download-artifact@v4
- name: Normalize arch names to x64 or arm64
run: |
find . -maxdepth 2 -type f -name "*" | while read -r file; do
filename=$(basename "$file")
newname=$(echo "$filename" | sed -e 's/amd64/x64/g' -e 's/x86_64/x64/g' -e 's/aarch64/arm64/g')
if [ "$filename" != "$newname" ]; then
mv -v "$file" "$newname"
fi
done
- name: Publish to GitHub Releases
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ github.ref }}
prerelease: true
file: ./**/*
file_glob: true
repo_token: ${{ secrets.GITHUB_TOKEN }}
submit-winget:
name: Submit to WinGet repository
needs: publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# wingetcreate only runs on Windows
runs-on: windows-latest
steps:
- name: Submit package using wingetcreate
run: |
$packageVersion = "${{ github.ref }}" -replace 'refs/tags/v', ''
$installerUrl = "https://github.com/httptoolkit/httptoolkit-desktop/releases/download/v$packageVersion/HttpToolkit-$packageVersion.exe"
# Update package using wingetcreate
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update HTTPToolKit.HTTPToolKit `
--version $packageVersion `
--urls "$installerUrl|x64" `
--submit `
--token "${{ secrets.WINGET_GITHUB_TOKEN }}"