-
Notifications
You must be signed in to change notification settings - Fork 89
127 lines (117 loc) · 4.33 KB
/
ci.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
name: CI
on: push
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-2019"
- platform: mac
arch: x64
os: "macos-13"
- platform: mac
arch: arm64
os: "macos-14"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.18.1
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:
- run: echo "$APPLE_API_KEY" > ./apple-api-key.p8
if: startsWith(matrix.os, 'macos-')
env:
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
- run: npm run build
env:
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' }}
- 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"
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: build
steps:
- name: Get all distributables
uses: actions/download-artifact@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
prerelease: true
- 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: Upload Release Assets
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: ./*/
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 }}"