-
Notifications
You must be signed in to change notification settings - Fork 9
289 lines (239 loc) · 8.59 KB
/
publish.yml
File metadata and controls
289 lines (239 loc) · 8.59 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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: Build and release Git-Mastery CLI
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
permissions:
contents: write
pull-requests: write
packages: read
issues: read
jobs:
linux-build:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Get binary name
id: binary-name
env:
OS_VERSION: ${{ matrix.os }}
run: |
if [ $OS_VERSION = "ubuntu-latest" ]; then
ARCHITECTURE=amd64
else
ARCHITECTURE=arm64
fi
FILENAME=gitmastery-${GITHUB_REF_NAME#v}-linux-$ARCHITECTURE
echo "binary=$FILENAME" >> $GITHUB_OUTPUT
- name: Build binary
env:
BINARY_NAME: ${{ steps.binary-name.outputs.binary }}
run: |
pyinstaller --onefile main.py --name $BINARY_NAME
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/${{ steps.binary-name.outputs.binary }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.binary-name.outputs.binary }}
path: dist/${{ steps.binary-name.outputs.binary }}
debian-build:
needs: linux-build
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
path: "app"
- name: Extract variables
env:
ARCHITECTURE: ${{ matrix.architecture }}
OS_VERSION: ${{ matrix.os }}
run: |
if [ $OS_VERSION = "ubuntu-latest" ]; then
ARCHITECTURE=amd64
else
ARCHITECTURE=arm64
fi
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
echo "ARCHITECTURE=${ARCHITECTURE}" >> $GITHUB_ENV
# Get the tag's commit message
cd app/
CHANGELOG_MESSAGE=$(git show ${GITHUB_REF_NAME} --no-patch --pretty=format:%s)
echo "CHANGELOG_MESSAGE=${CHANGELOG_MESSAGE}" >> $GITHUB_ENV
- name: Install Debian packaging tools
run: |
sudo apt-get install devscripts build-essential debhelper-compat
- name: Create folder structure for ${{ env.ARCHITECTURE }} distribution
run: |
mkdir gitmastery-${VERSION}-${ARCHITECTURE}
- name: Download ${{ env.ARCHITECTURE }} binaries from artifacts
uses: actions/download-artifact@v4
with:
name: gitmastery-${{ env.VERSION }}-linux-${{ env.ARCHITECTURE }}
path: gitmastery-${{ env.VERSION }}-${{ env.ARCHITECTURE }}/
- name: Create upstream tarball .orig.tar.gz
run: |
# Create .orig.tar.gz file
tar -czf gitmastery_${VERSION}.orig.tar.gz gitmastery-${VERSION}-${ARCHITECTURE}/gitmastery-${VERSION}-linux-${ARCHITECTURE}
tree
- name: Generate Debian packaging files
working-directory: gitmastery-${{ env.VERSION }}-${{ env.ARCHITECTURE }}
# TODO: Update to something agnostic
env:
EMAIL: woojiahao1234@gmail.com
NAME: Jiahao, Woo
run: |
file gitmastery-${VERSION}-linux-${ARCHITECTURE}
# Create the debian folder
mkdir debian
# Generate the changelog
# TODO: Maybe detect if major version change, then make it urgent
dch --create -v ${VERSION}-1 -u low --package gitmastery $CHANGELOG_MESSAGE
# Create the control file
# TODO: Maybe detect if major version change, then make it mandatory
echo """Source: gitmastery
Maintainer: $NAME <$EMAIL>
Section: misc
Priority: optional
Standards-Version: 4.7.0
Build-Depends: debhelper-compat (= 13)
Package: gitmastery
Architecture: ${ARCHITECTURE}
Depends: ${shlibs:Depends}, ${misc:Depends}, libc6 (>= 2.35), python3
Description: execute Git-Mastery
gitmastery is a Git learning tool built by the National University of Singapore School of Computing
""" > debian/control
# Copy over the MIT license from the main app to this release
cat ../app/LICENSE > debian/copyright
mkdir debian/source
echo "3.0 (quilt)" > debian/source/format
# Provide the rules for installation, using -e to preserve the tab character as per:
# https://wiki.debian.org/Packaging/Intro
echo -e $"""#!/usr/bin/make -f
%:
\tdh \$@
\n
override_dh_auto_install:
\tinstall -D -m 0755 gitmastery-${VERSION}-linux-${ARCHITECTURE} debian/gitmastery/usr/bin/gitmastery
""" > debian/rules
echo """usr/bin
""" > debian/gitmastery.dirs
mkdir -p debian/source
echo """gitmastery-${VERSION}-linux-${ARCHITECTURE}
""" > debian/source/include-binaries
cat debian/rules
# Build the package
dpkg-buildpackage -us -uc -a ${ARCHITECTURE}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: gitmastery_${{ env.VERSION }}-1_${{ env.ARCHITECTURE }}.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
debian-publish-apt:
needs: debian-build
uses: git-mastery/gitmastery-apt-repo/.github/workflows/debian-apt-repo.yml@main
with:
version: ${{ env.VERSION }}
secrets: inherit
windows:
runs-on: windows-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build binary
run: |
pyinstaller --onefile --name gitmastery main.py
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/gitmastery.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
macos:
runs-on: macos-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build binary
run: |
pyinstaller --onefile --name gitmastery main.py
- name: Generate SHA256
id: checksum
run: |
FILENAME=gitmastery
SHA256=$(shasum -a 256 dist/$FILENAME | cut -d ' ' -f1)
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/gitmastery
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Homebrew Tap
env:
GH_TOKEN: ${{ secrets.ORG_PAT }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git clone https://x-access-token:${GH_TOKEN}@github.com/git-mastery/homebrew-gitmastery.git
cd homebrew-gitmastery
ls
cat <<EOF > gitmastery.rb
class Gitmastery < Formula
desc "CLI tool for Git-Mastery"
homepage "https://github.com/git-mastery/cli"
url "https://github.com/git-mastery/cli/releases/download/${GITHUB_REF_NAME}/gitmastery"
sha256 "${{ steps.checksum.outputs.sha256 }}"
version "${GITHUB_REF_NAME#v}"
def install
chmod 0755, "gitmastery"
bin.install "gitmastery"
end
test do
system "#{bin}/gitmastery", "--help"
end
end
EOF
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/git-mastery/homebrew-gitmastery.git
git remote -v
git add gitmastery.rb
git commit -m "Update to ${GITHUB_REF_NAME}"
git push origin main