Skip to content

Commit 9f796e6

Browse files
committed
Implement a GitHub Actions worfklow to do releases for us
No signing at this moment but from the 81 commits I did in the other branch (mostly over this lovely quarantined weekend) you can tell I'm probably fed up with this. Cleanup and macOS signing/notarization hopefully coming at some point in the future. No Windows signing on the horizon though, because I don't really want/need a Windows code signing certificate. There's a PR by @probonopd to create a Travis workflow for AppImages, I'd like to add that here too. And finally, there should be a release script that just modifies our repo on flathub and does the releases for us.
1 parent 8c10fa8 commit 9f796e6

9 files changed

+591
-50
lines changed

.github/workflows/ccpp.yml

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
name: Automatic build
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
release:
8+
types: [ created ]
9+
10+
jobs:
11+
Linux:
12+
if: github.event_name == 'push'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
with:
17+
fetch-depth: 1
18+
- name: Install dependencies
19+
run: |
20+
sudo apt update
21+
sudo apt install libxss1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 qt5-default libqt5gui5 libqt5webengine5 libqt5webenginecore5 libqt5webenginewidgets5 libqt5printsupport5 libqt5quickwidgets5 qml-module-qtquick-controls libqt5x11extras5 binutils cmake pkg-config qtbase5-dev qtwebengine5-dev libqt5x11extras5-dev qtbase5-private-dev libssl-dev libxss-dev libxmu-dev
22+
- name: Configure
23+
run: qmake .
24+
- name: Build
25+
run: make -j2
26+
27+
Flatpak:
28+
if: github.event_name == 'release'
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v1
32+
with:
33+
fetch-depth: 1
34+
- name: Install dependencies
35+
run: |
36+
sudo apt update
37+
sudo apt install flatpak flatpak-builder
38+
- name: Install Flatpak KDE SDK
39+
run: |
40+
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
41+
sudo flatpak install --system -y flathub org.kde.Platform//5.14
42+
sudo flatpak install --system -y flathub org.kde.Sdk//5.14
43+
- name: Build the Flatpak package
44+
run: |
45+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
46+
pushd dist/flatpak
47+
sudo flatpak-builder --repo=flatpak-repo --force-clean flatpak-build org.fedoraproject.MediaWriter.json
48+
flatpak build-bundle flatpak-repo org.fedoraproject.MediaWriter.flatpak org.fedoraproject.MediaWriter
49+
mv org.fedoraproject.MediaWriter.flatpak ../../org.fedoraproject.MediaWriter-$TAG_NAME.flatpak
50+
popd
51+
- name: Upload to GitHub
52+
if: github.event_name == 'release'
53+
shell: bash
54+
run: |
55+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
56+
bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="org.fedoraproject.MediaWriter-$TAG_NAME.flatpak"
57+
58+
macOS:
59+
runs-on: macos-latest
60+
steps:
61+
- uses: actions/checkout@v1
62+
with:
63+
fetch-depth: 1
64+
- name: Install dependencies
65+
run: |
66+
brew install qt
67+
echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile
68+
brew install xz
69+
brew install git
70+
npm install -g create-dmg
71+
- name: Configure
72+
run: |
73+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
74+
bash dist/mac/build.sh configure
75+
- name: Build
76+
run: |
77+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
78+
bash dist/mac/build.sh build
79+
- name: Insert dependencies
80+
if: github.event_name == 'release'
81+
run: |
82+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
83+
bash dist/mac/build.sh deps
84+
- name: Sign (TBD)
85+
if: github.event_name == 'release'
86+
run: |
87+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
88+
true # bash dist/mac/build.sh sign
89+
- name: Package
90+
if: github.event_name == 'release'
91+
run: |
92+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
93+
cd build/app
94+
create-dmg "Fedora Media Writer.app" || true # without signing, create-dmg returns an error code
95+
mv Fedora*.dmg ../../FedoraMediaWriter-osx-$TAG_NAME.unnotarized.dmg
96+
- name: Notarize (TBD)
97+
if: github.event_name == 'release'
98+
run: |
99+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
100+
true # bash dist/mac/build.sh notarize
101+
- name: Upload to GitHub
102+
if: github.event_name == 'release'
103+
shell: bash
104+
run: |
105+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
106+
bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="FedoraMediaWriter-osx-$TAG_NAME.unnotarized.dmg"
107+
108+
Windows:
109+
runs-on: windows-latest
110+
steps:
111+
- uses: actions/checkout@v1
112+
with:
113+
fetch-depth: 1
114+
- name: Cache Qt
115+
id: cache-qt
116+
uses: actions/cache@v1
117+
with:
118+
path: d:/a/MediaWriter/Qt
119+
key: QtCache
120+
- name: Install dependencies
121+
shell: bash
122+
run: |
123+
choco install nsis
124+
choco install dos2unix
125+
- name: Install Qt
126+
uses: jurplel/install-qt-action@v2
127+
with:
128+
cached: ${{ steps.cache-qt.outputs.cache-hit }}
129+
arch: win64_mingw73
130+
- name: Build xz-utils
131+
shell: bash
132+
if: ${{ !steps.cache-qt.outputs.cache-hit }}
133+
run: |
134+
git clone https://git.tukaani.org/xz.git
135+
sed -i 's/#include "config.h"//' xz/src/common/common_w32res.rc
136+
sed -i 's/PACKAGE_NAME/"liblzma"/' xz/src/common/common_w32res.rc
137+
sed -i 's/PACKAGE_URL/"https:\/\/tukaani.org\/xz\/"/' xz/src/common/common_w32res.rc
138+
mkdir xz/build
139+
cd xz/build
140+
cmake -DCMAKE_SH="CMAKE_SH-NOTFOUND" -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="$Qt5_Dir" -DBUILD_SHARED_LIBS=ON ..
141+
mingw32-make -j2 VERBOSE=1
142+
mingw32-make install
143+
# ugh
144+
cp "$Qt5_Dir/bin/liblzma.dll" "$Qt5_Dir/bin/libliblzma.dll"
145+
- name: Build MediaWriter
146+
shell: bash
147+
run: |
148+
#export PATH=$(echo "$PATH" | sed -e 's/:\/c\/ProgramData\/Chocolatey\/bin//' | sed -e 's/:\/c\/Strawberry\/c\/bin//')
149+
#export PATH="$Qt5_Dir/../../Tools/mingw730_32/bin:$PATH"
150+
mkdir build
151+
cd build
152+
"$Qt5_Dir/bin/qmake" ..
153+
mingw32-make -j2 VERBOSE=1
154+
- name: Windeployqt
155+
if: github.event_name == 'release'
156+
shell: bash
157+
run: |
158+
cd build/app/release
159+
mv ../helper.exe .
160+
$Qt5_Dir/bin/windeployqt -qmldir ../../.. mediawriter.exe
161+
cp $Qt5_Dir/bin/libstdc*.dll .
162+
cp $Qt5_Dir/bin/libwinpthread*.dll .
163+
cp $Qt5_Dir/bin/libgcc*.dll .
164+
cp /c/Program\ Files/OpenSSL/bin/*.dll .
165+
- name: Installer
166+
if: github.event_name == 'release'
167+
shell: bash
168+
run: |
169+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
170+
171+
VERSION_STRIPPED=$(sed "s/-.*//" <<< "${TAG_NAME}")
172+
if [[ "$VERSION_STRIPPED" == "" ]]; then
173+
VERSION_STRIPPED=0.0.0
174+
fi
175+
VERSION_MAJOR=$(cut -d. -f1 <<< "${VERSION_STRIPPED}")
176+
VERSION_MINOR=$(cut -d. -f2 <<< "${VERSION_STRIPPED}")
177+
VERSION_BUILD=$(cut -d. -f3 <<< "${VERSION_STRIPPED}")
178+
INSTALLED_SIZE=$(du -k -d0 "build/app/release" | cut -f1)
179+
180+
cp "dist/win/mediawriter_native.nsi" "dist/win/mediawriter_native.tmp.nsi"
181+
182+
sed -i "s/#!define VERSIONMAJOR/!define VERSIONMAJOR ${VERSION_MAJOR}/" "dist/win/mediawriter_native.tmp.nsi"
183+
sed -i "s/#!define VERSIONMINOR/!define VERSIONMINOR ${VERSION_MINOR}/" "dist/win/mediawriter_native.tmp.nsi"
184+
sed -i "s/#!define VERSIONBUILD/!define VERSIONBUILD ${VERSION_BUILD}/" "dist/win/mediawriter_native.tmp.nsi"
185+
sed -i "s/#!define INSTALLSIZE/!define INSTALLSIZE ${INSTALLED_SIZE}/" "dist/win/mediawriter_native.tmp.nsi"
186+
187+
unix2dos < "LICENSE" > "build/app/release/LICENSE.txt"
188+
makensis -DCERTPATH="" -DCERTPASS="" dist/win/mediawriter_native.tmp.nsi
189+
mv dist/win/FMW-setup.exe ./"FedoraMediaWriter-win64-$TAG_NAME.exe"
190+
- name: Upload to GitHub
191+
if: github.event_name == 'release'
192+
shell: bash
193+
run: |
194+
TAG_NAME=$(bash ./dist/get-tag-name.sh)
195+
bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="FedoraMediaWriter-win64-$TAG_NAME.exe"

app/Info.plist

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<dict>
55
<key>NSPrincipalClass</key>
66
<string>NSApplication</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>Fedora Media Writer</string>
79
<key>CFBundleIconFile</key>
810
<string>@ICON@</string>
911
<key>CFBundlePackageType</key>

deployment.pri

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ linux {
1616
QMAKE_LIBDIR += $$top_builddir/lib
1717
INCLUDEPATH += $$top_srcdir/lib/
1818
isEmpty(MEDIAWRITER_VERSION) {
19-
MEDIAWRITER_VERSION=$$quote($$system(git -C \""$$_PRO_FILE_PWD_"\" describe --tags || echo N/A))
19+
MEDIAWRITER_VERSION=$$quote($$system(git -C \""$$_PRO_FILE_PWD_"\" describe --tags || echo "Not-Available"))
2020
}
2121
MEDIAWRITER_VERSION_SHORT=$$section(MEDIAWRITER_VERSION,-,0,0)
2222
DEFINES += MEDIAWRITER_VERSION="\\\"$$MEDIAWRITER_VERSION\\\""

dist/flatpak/org.fedoraproject.MediaWriter.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "org.fedoraproject.MediaWriter",
33
"runtime": "org.kde.Platform",
4-
"runtime-version": "5.12",
4+
"runtime-version": "5.14",
55
"sdk": "org.kde.Sdk",
66
"command": "mediawriter",
77
"rename-appdata-file": "mediawriter.appdata.xml",

dist/get-tag-name.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
PROBABLY_TAG=${GITHUB_REF/refs\/tags\//}
4+
5+
grep "^[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*$" <<< "$PROBABLY_TAG"
6+
7+
exit 0

dist/mac/build.sh

+87-45
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/bash
22

3+
set -x
4+
set -e
5+
6+
PATH="/usr/local/opt/qt/bin:/usr/local/opt/git/bin:$PATH"
7+
38
DEVELOPER_ID="Mac Developer: Martin Briza (N952V7G2F5)"
4-
QT_ROOT="${HOME}/Qt/5.12.1/clang_64"
9+
QT_ROOT="/usr/local/opt/qt"
510
QMAKE="${QT_ROOT}/bin/qmake"
611
MACDEPLOYQT="${QT_ROOT}/bin/macdeployqt"
712
NOTARIZATION_EMAIL=""
@@ -14,53 +19,90 @@ popd >/dev/null
1419

1520
cd "${SCRIPTDIR}/../.."
1621

17-
INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$(git describe --tags).dmg"
18-
19-
rm -fr "build"
20-
mkdir -p "build"
21-
pushd build >/dev/null
22-
23-
echo "=== Building ==="
24-
${QMAKE} .. >/dev/null
25-
make -j9 >/dev/null
26-
27-
echo "=== Inserting Qt deps ==="
28-
cp "helper/mac/helper.app/Contents/MacOS/helper" "app/Fedora Media Writer.app/Contents/MacOS"
29-
${MACDEPLOYQT} "app/Fedora Media Writer.app" -qmldir="../app" -executable="app/Fedora Media Writer.app/Contents/MacOS/helper"
30-
31-
echo "=== Checking unresolved library deps ==="
32-
# Look at the binaries and search for dynamic library dependencies that are not included on every system
33-
# So far, this finds only liblzma but in the future it may be necessary for more libs
34-
for binary in "helper" "Fedora Media Writer"; do
35-
otool -L "app/Fedora Media Writer.app/Contents/MacOS/$binary" |\
36-
grep -E "^\s" | grep -Ev "Foundation|OpenGL|AGL|DiskArbitration|IOKit|libc\+\+|libobjc|libSystem|@rpath" |\
37-
sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\
38-
while read library; do
39-
if [[ ! $library == @loader_path/* ]]; then
40-
echo "Copying $(basename $library)"
41-
cp $library "app/Fedora Media Writer.app/Contents/Frameworks"
42-
install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "app/Fedora Media Writer.app/Contents/MacOS/$binary"
43-
fi
22+
if [[ "$TAG_NAME" == "" ]]; then
23+
VERSION=$(git describe --tags --always)
24+
else
25+
VERSION="$TAG_NAME"
26+
fi
27+
28+
INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$VERSION.dmg"
29+
30+
function configure() {
31+
rm -fr "build"
32+
mkdir -p "build"
33+
pushd build >/dev/null
34+
35+
echo "=== Building ==="
36+
${QMAKE} ..
37+
popd >/dev/null
38+
}
39+
40+
function build() {
41+
pushd build >/dev/null
42+
make -j9
43+
popd >/dev/null
44+
}
45+
46+
function deps() {
47+
pushd build >/dev/null
48+
echo "=== Inserting Qt deps ==="
49+
cp "helper/mac/helper.app/Contents/MacOS/helper" "app/Fedora Media Writer.app/Contents/MacOS"
50+
${MACDEPLOYQT} "app/Fedora Media Writer.app" -qmldir="../app" -executable="app/Fedora Media Writer.app/Contents/MacOS/helper"
51+
52+
echo "=== Checking unresolved library deps ==="
53+
# Look at the binaries and search for dynamic library dependencies that are not included on every system
54+
# So far, this finds only liblzma but in the future it may be necessary for more libs
55+
for binary in "helper" "Fedora Media Writer"; do
56+
otool -L "app/Fedora Media Writer.app/Contents/MacOS/$binary" |\
57+
grep -E "^\s" | grep -Ev "Foundation|OpenGL|AGL|DiskArbitration|IOKit|libc\+\+|libobjc|libSystem|@rpath" |\
58+
sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\
59+
while read library; do
60+
if [[ ! $library == @loader_path/* ]]; then
61+
echo "Copying $(basename $library)"
62+
cp $library "app/Fedora Media Writer.app/Contents/Frameworks"
63+
install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "app/Fedora Media Writer.app/Contents/MacOS/$binary"
64+
fi
65+
done
4466
done
45-
done
67+
popd >/dev/null
68+
}
4669

47-
echo "=== Signing the package ==="
48-
# sign all frameworks and then the package
49-
find app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do
50-
codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime
51-
done
52-
codesign -s "$DEVELOPER_ID" --deep -v -f app/Fedora\ Media\ Writer.app/ -o runtime
70+
function sign() {
71+
pushd build >/dev/null
72+
echo "=== Signing the package ==="
73+
# sign all frameworks and then the package
74+
find app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do
75+
codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime
76+
done
77+
codesign -s "$DEVELOPER_ID" --deep -v -f app/Fedora\ Media\ Writer.app/ -o runtime
78+
popd >/dev/null
79+
}
5380

54-
echo "=== Creating a disk image ==="
55-
# create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting)
56-
rm -f ../FedoraMediaWriter-osx-$(git describe --tags).dmg
57-
hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$(git describe --tags).unnotarized.dmg
81+
function dmg() {
82+
pushd build >/dev/null
83+
echo "=== Creating a disk image ==="
84+
# create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting)
85+
rm -f "../FedoraMediaWriter-osx-$VERSION.dmg"
86+
hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg
87+
popd >/dev/null
88+
}
5889

59-
echo "=== Submitting for notarization ==="
60-
xcrun altool --notarize-app --primary-bundle-id "org.fedoraproject.mediawriter" --username "${NOTARIZATION_EMAIL}" --password "@keychain:${NOTARIZATION_KEYCHAIN_ITEM}" --asc-provider "${NOTARIZATION_ITUNES_ORGID}" --file "../FedoraMediaWriter-osx-$(git describe --tags).unnotarized.dmg"
90+
function notarize() {
91+
echo "=== Submitting for notarization ==="
92+
xcrun altool --notarize-app --primary-bundle-id "org.fedoraproject.mediawriter" --username "${NOTARIZATION_EMAIL}" --password "@keychain:${NOTARIZATION_KEYCHAIN_ITEM}" --asc-provider "${NOTARIZATION_ITUNES_ORGID}" --file "../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg"
6193

62-
echo "DONE. After notarization finished (you'll get an email), run:"
63-
echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app"
64-
echo "$ hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$(git describe --tags).dmg"
94+
echo "DONE. After notarization finished (you'll get an email), run:"
95+
echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app"
96+
echo "$ hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.dmg"
97+
}
6598

66-
popd >/dev/null
99+
if [[ $# -eq 0 ]]; then
100+
configure
101+
build
102+
deps
103+
sign
104+
dmg
105+
notarize
106+
else
107+
$1
108+
fi

0 commit comments

Comments
 (0)