-
Notifications
You must be signed in to change notification settings - Fork 108
192 lines (184 loc) · 7.66 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
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
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
run: |
sudo apt-get install shellcheck
shopt -s globstar; shellcheck script/**/*.sh
build:
name: ${{ matrix.friendlyName }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-14, windows-2019, ubuntu-20.04]
arch: [x86, x64]
include:
- os: macos-14
friendlyName: macOS
targetPlatform: macOS
- os: macos-14
friendlyName: macOS
targetPlatform: macOS
arch: arm64
- os: windows-2019
friendlyName: Windows
targetPlatform: win32
- os: ubuntu-20.04
friendlyName: Linux
targetPlatform: ubuntu
- os: ubuntu-20.04
friendlyName: Linux
targetPlatform: ubuntu
arch: arm64
- os: ubuntu-20.04
friendlyName: Linux
targetPlatform: ubuntu
arch: arm
exclude:
- os: macos-14
arch: x86
timeout-minutes: 20
steps:
- name: Install dependencies into dockerfile on Ubuntu
if: matrix.targetPlatform == 'ubuntu'
run: |
# ubuntu dockerfile is very minimal (only 122 packages are installed)
# add dependencies expected by scripts
sudo apt update
sudo apt install -y software-properties-common lsb-release sudo wget curl build-essential jq autoconf automake pkg-config ca-certificates
# install new enough git to run actions/checkout
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt update
sudo apt install -y git
# install new enough npm/nodejs to build dugite-native
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
# avoid "fatal: detected dubious ownership in repository at '/__w/dugite-native/dugite-native'" error
git config --global --add safe.directory '*'
# We need to use Xcode 11.7 for maximum compatibility with older macOS (x64)
- name: Switch to Xcode 11.7
if: matrix.targetPlatform == 'macOS' && matrix.arch == 'x64'
run: |
sudo xcode-select -s /Applications/Xcode_11.7.app/Contents/Developer/
# Delete the command line tools to make sure they don't get our builds
# messed up with macOS SDK 11 stuff.
sudo rm -rf /Library/Developer/CommandLineTools
- uses: actions/checkout@v3
with:
submodules: recursive
# Needed for script/package.sh to work
fetch-depth: 0
- name: Install go
if: matrix.targetPlatform == 'macOS'
uses: actions/setup-go@v5
- name: Install dependencies
run: npm install
- name: Check formatting
run: npm run prettier
- name: Build tools
run: npm run check
- name: Install extra dependencies for building Git on Ubuntu (x64)
if: matrix.targetPlatform == 'ubuntu' && matrix.arch == 'x64'
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-gnutls-dev libexpat1-dev zlib1g-dev gettext libssl-dev
- name: Install extra dependencies for building Git on Ubuntu (x86)
if: matrix.targetPlatform == 'ubuntu' && matrix.arch == 'x86'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-i686-linux-gnu binutils-i686-gnu libcurl4-gnutls-dev:i386 zlib1g-dev:i386 libssl-dev:i386 gettext
- name: Install extra dependencies for building Git on Ubuntu (arm64)
if: matrix.targetPlatform == 'ubuntu' && matrix.arch == 'arm64'
run: |
sudo sed -i "s/^deb/deb [arch=amd64,i386]/g" /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://azure.ports.ubuntu.com/ $(lsb_release -s -c) main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://azure.ports.ubuntu.com/ $(lsb_release -s -c)-updates main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture arm64
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libcurl4-gnutls-dev:arm64 zlib1g-dev:arm64 libssl-dev:arm64 gettext
- name: Install extra dependencies for building Git on Ubuntu (arm)
if: matrix.targetPlatform == 'ubuntu' && matrix.arch == 'arm'
run: |
sudo sed -i "s/^deb/deb [arch=amd64,i386]/g" /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://azure.ports.ubuntu.com/ $(lsb_release -s -c) main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=arm64,armhf] http://azure.ports.ubuntu.com/ $(lsb_release -s -c)-updates main universe multiverse restricted" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libcurl4-gnutls-dev:armhf zlib1g-dev:armhf libssl-dev:armhf gettext
- name: Build (except macOS arm64)
if: matrix.targetPlatform != 'macOS' || matrix.arch != 'arm64'
shell: bash
run: script/build.sh
env:
TARGET_PLATFORM: ${{ matrix.targetPlatform }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Build (macOS arm64)
if: matrix.targetPlatform == 'macOS' && matrix.arch == 'arm64'
shell: bash
run: script/build.sh
env:
TARGET_PLATFORM: ${{ matrix.targetPlatform }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Package
shell: bash
run: script/package.sh
env:
TARGET_PLATFORM: ${{ matrix.targetPlatform }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Upload output artifacts
uses: actions/upload-artifact@v4
with:
name:
dugite-native-${{ matrix.targetPlatform }}-${{ matrix.arch }}-output
path: ./output
retention-days: 5
release:
name: Create GitHub release
needs: [build, shellcheck]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: './artifacts'
- name: Display structure of downloaded files
run: ls -R
working-directory: './artifacts'
- name: Generate release notes
run: |
npm ci
DUGITE_TAG=${GITHUB_REF/refs\/tags\//}
node -r ts-node/register script/generate-release-notes.ts "${{ github.workspace }}/artifacts" "$DUGITE_TAG" "${{ secrets.GITHUB_TOKEN }}"
RELEASE_NOTES_FILE=script/release_notes.txt
if [[ ! -f "$RELEASE_NOTES_FILE" ]]; then
echo "$RELEASE_NOTES_FILE does not exist. Something might have gone wrong while generating the release notes."
exit 1
fi
echo 'DUGITE_RELEASE_NOTES<<EOF' >> $GITHUB_ENV
cat ${RELEASE_NOTES_FILE} >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v2
with:
body: ${{ env.DUGITE_RELEASE_NOTES }}
draft: true
prerelease: false
files: ${{ github.workspace }}/artifacts/**/*
fail_on_unmatched_files: true