Skip to content

Commit

Permalink
Implement a GitHub Actions worfklow to do releases for us
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MartinBriza committed Mar 29, 2020
1 parent 8c10fa8 commit 9f796e6
Show file tree
Hide file tree
Showing 9 changed files with 591 additions and 50 deletions.
195 changes: 195 additions & 0 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
name: Automatic build

on:
push:
branches:
- '**'
release:
types: [ created ]

jobs:
Linux:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install dependencies
run: |
sudo apt update
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
- name: Configure
run: qmake .
- name: Build
run: make -j2

Flatpak:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install dependencies
run: |
sudo apt update
sudo apt install flatpak flatpak-builder
- name: Install Flatpak KDE SDK
run: |
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak install --system -y flathub org.kde.Platform//5.14
sudo flatpak install --system -y flathub org.kde.Sdk//5.14
- name: Build the Flatpak package
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
pushd dist/flatpak
sudo flatpak-builder --repo=flatpak-repo --force-clean flatpak-build org.fedoraproject.MediaWriter.json
flatpak build-bundle flatpak-repo org.fedoraproject.MediaWriter.flatpak org.fedoraproject.MediaWriter
mv org.fedoraproject.MediaWriter.flatpak ../../org.fedoraproject.MediaWriter-$TAG_NAME.flatpak
popd
- name: Upload to GitHub
if: github.event_name == 'release'
shell: bash
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="org.fedoraproject.MediaWriter-$TAG_NAME.flatpak"
macOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install dependencies
run: |
brew install qt
echo 'export PATH="/usr/local/opt/qt/bin:$PATH"' >> ~/.bash_profile
brew install xz
brew install git
npm install -g create-dmg
- name: Configure
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
bash dist/mac/build.sh configure
- name: Build
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
bash dist/mac/build.sh build
- name: Insert dependencies
if: github.event_name == 'release'
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
bash dist/mac/build.sh deps
- name: Sign (TBD)
if: github.event_name == 'release'
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
true # bash dist/mac/build.sh sign
- name: Package
if: github.event_name == 'release'
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
cd build/app
create-dmg "Fedora Media Writer.app" || true # without signing, create-dmg returns an error code
mv Fedora*.dmg ../../FedoraMediaWriter-osx-$TAG_NAME.unnotarized.dmg
- name: Notarize (TBD)
if: github.event_name == 'release'
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
true # bash dist/mac/build.sh notarize
- name: Upload to GitHub
if: github.event_name == 'release'
shell: bash
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="FedoraMediaWriter-osx-$TAG_NAME.unnotarized.dmg"
Windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Cache Qt
id: cache-qt
uses: actions/cache@v1
with:
path: d:/a/MediaWriter/Qt
key: QtCache
- name: Install dependencies
shell: bash
run: |
choco install nsis
choco install dos2unix
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
cached: ${{ steps.cache-qt.outputs.cache-hit }}
arch: win64_mingw73
- name: Build xz-utils
shell: bash
if: ${{ !steps.cache-qt.outputs.cache-hit }}
run: |
git clone https://git.tukaani.org/xz.git
sed -i 's/#include "config.h"//' xz/src/common/common_w32res.rc
sed -i 's/PACKAGE_NAME/"liblzma"/' xz/src/common/common_w32res.rc
sed -i 's/PACKAGE_URL/"https:\/\/tukaani.org\/xz\/"/' xz/src/common/common_w32res.rc
mkdir xz/build
cd xz/build
cmake -DCMAKE_SH="CMAKE_SH-NOTFOUND" -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="$Qt5_Dir" -DBUILD_SHARED_LIBS=ON ..
mingw32-make -j2 VERBOSE=1
mingw32-make install
# ugh
cp "$Qt5_Dir/bin/liblzma.dll" "$Qt5_Dir/bin/libliblzma.dll"
- name: Build MediaWriter
shell: bash
run: |
#export PATH=$(echo "$PATH" | sed -e 's/:\/c\/ProgramData\/Chocolatey\/bin//' | sed -e 's/:\/c\/Strawberry\/c\/bin//')
#export PATH="$Qt5_Dir/../../Tools/mingw730_32/bin:$PATH"
mkdir build
cd build
"$Qt5_Dir/bin/qmake" ..
mingw32-make -j2 VERBOSE=1
- name: Windeployqt
if: github.event_name == 'release'
shell: bash
run: |
cd build/app/release
mv ../helper.exe .
$Qt5_Dir/bin/windeployqt -qmldir ../../.. mediawriter.exe
cp $Qt5_Dir/bin/libstdc*.dll .
cp $Qt5_Dir/bin/libwinpthread*.dll .
cp $Qt5_Dir/bin/libgcc*.dll .
cp /c/Program\ Files/OpenSSL/bin/*.dll .
- name: Installer
if: github.event_name == 'release'
shell: bash
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
VERSION_STRIPPED=$(sed "s/-.*//" <<< "${TAG_NAME}")
if [[ "$VERSION_STRIPPED" == "" ]]; then
VERSION_STRIPPED=0.0.0
fi
VERSION_MAJOR=$(cut -d. -f1 <<< "${VERSION_STRIPPED}")
VERSION_MINOR=$(cut -d. -f2 <<< "${VERSION_STRIPPED}")
VERSION_BUILD=$(cut -d. -f3 <<< "${VERSION_STRIPPED}")
INSTALLED_SIZE=$(du -k -d0 "build/app/release" | cut -f1)
cp "dist/win/mediawriter_native.nsi" "dist/win/mediawriter_native.tmp.nsi"
sed -i "s/#!define VERSIONMAJOR/!define VERSIONMAJOR ${VERSION_MAJOR}/" "dist/win/mediawriter_native.tmp.nsi"
sed -i "s/#!define VERSIONMINOR/!define VERSIONMINOR ${VERSION_MINOR}/" "dist/win/mediawriter_native.tmp.nsi"
sed -i "s/#!define VERSIONBUILD/!define VERSIONBUILD ${VERSION_BUILD}/" "dist/win/mediawriter_native.tmp.nsi"
sed -i "s/#!define INSTALLSIZE/!define INSTALLSIZE ${INSTALLED_SIZE}/" "dist/win/mediawriter_native.tmp.nsi"
unix2dos < "LICENSE" > "build/app/release/LICENSE.txt"
makensis -DCERTPATH="" -DCERTPASS="" dist/win/mediawriter_native.tmp.nsi
mv dist/win/FMW-setup.exe ./"FedoraMediaWriter-win64-$TAG_NAME.exe"
- name: Upload to GitHub
if: github.event_name == 'release'
shell: bash
run: |
TAG_NAME=$(bash ./dist/get-tag-name.sh)
bash ./dist/upload-to-github.sh github_api_token=${{ secrets.GITHUB_TOKEN }} tag="$TAG_NAME" filename="FedoraMediaWriter-win64-$TAG_NAME.exe"
2 changes: 2 additions & 0 deletions app/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleDisplayName</key>
<string>Fedora Media Writer</string>
<key>CFBundleIconFile</key>
<string>@ICON@</string>
<key>CFBundlePackageType</key>
Expand Down
2 changes: 1 addition & 1 deletion deployment.pri
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ linux {
QMAKE_LIBDIR += $$top_builddir/lib
INCLUDEPATH += $$top_srcdir/lib/
isEmpty(MEDIAWRITER_VERSION) {
MEDIAWRITER_VERSION=$$quote($$system(git -C \""$$_PRO_FILE_PWD_"\" describe --tags || echo N/A))
MEDIAWRITER_VERSION=$$quote($$system(git -C \""$$_PRO_FILE_PWD_"\" describe --tags || echo "Not-Available"))
}
MEDIAWRITER_VERSION_SHORT=$$section(MEDIAWRITER_VERSION,-,0,0)
DEFINES += MEDIAWRITER_VERSION="\\\"$$MEDIAWRITER_VERSION\\\""
2 changes: 1 addition & 1 deletion dist/flatpak/org.fedoraproject.MediaWriter.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "org.fedoraproject.MediaWriter",
"runtime": "org.kde.Platform",
"runtime-version": "5.12",
"runtime-version": "5.14",
"sdk": "org.kde.Sdk",
"command": "mediawriter",
"rename-appdata-file": "mediawriter.appdata.xml",
Expand Down
7 changes: 7 additions & 0 deletions dist/get-tag-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

PROBABLY_TAG=${GITHUB_REF/refs\/tags\//}

grep "^[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*$" <<< "$PROBABLY_TAG"

exit 0
132 changes: 87 additions & 45 deletions dist/mac/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash

set -x
set -e

PATH="/usr/local/opt/qt/bin:/usr/local/opt/git/bin:$PATH"

DEVELOPER_ID="Mac Developer: Martin Briza (N952V7G2F5)"
QT_ROOT="${HOME}/Qt/5.12.1/clang_64"
QT_ROOT="/usr/local/opt/qt"
QMAKE="${QT_ROOT}/bin/qmake"
MACDEPLOYQT="${QT_ROOT}/bin/macdeployqt"
NOTARIZATION_EMAIL=""
Expand All @@ -14,53 +19,90 @@ popd >/dev/null

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

INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$(git describe --tags).dmg"

rm -fr "build"
mkdir -p "build"
pushd build >/dev/null

echo "=== Building ==="
${QMAKE} .. >/dev/null
make -j9 >/dev/null

echo "=== Inserting Qt deps ==="
cp "helper/mac/helper.app/Contents/MacOS/helper" "app/Fedora Media Writer.app/Contents/MacOS"
${MACDEPLOYQT} "app/Fedora Media Writer.app" -qmldir="../app" -executable="app/Fedora Media Writer.app/Contents/MacOS/helper"

echo "=== Checking unresolved library deps ==="
# Look at the binaries and search for dynamic library dependencies that are not included on every system
# So far, this finds only liblzma but in the future it may be necessary for more libs
for binary in "helper" "Fedora Media Writer"; do
otool -L "app/Fedora Media Writer.app/Contents/MacOS/$binary" |\
grep -E "^\s" | grep -Ev "Foundation|OpenGL|AGL|DiskArbitration|IOKit|libc\+\+|libobjc|libSystem|@rpath" |\
sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\
while read library; do
if [[ ! $library == @loader_path/* ]]; then
echo "Copying $(basename $library)"
cp $library "app/Fedora Media Writer.app/Contents/Frameworks"
install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "app/Fedora Media Writer.app/Contents/MacOS/$binary"
fi
if [[ "$TAG_NAME" == "" ]]; then
VERSION=$(git describe --tags --always)
else
VERSION="$TAG_NAME"
fi

INSTALLER="$SCRIPTDIR/FedoraMediaWriter-osx-$VERSION.dmg"

function configure() {
rm -fr "build"
mkdir -p "build"
pushd build >/dev/null

echo "=== Building ==="
${QMAKE} ..
popd >/dev/null
}

function build() {
pushd build >/dev/null
make -j9
popd >/dev/null
}

function deps() {
pushd build >/dev/null
echo "=== Inserting Qt deps ==="
cp "helper/mac/helper.app/Contents/MacOS/helper" "app/Fedora Media Writer.app/Contents/MacOS"
${MACDEPLOYQT} "app/Fedora Media Writer.app" -qmldir="../app" -executable="app/Fedora Media Writer.app/Contents/MacOS/helper"

echo "=== Checking unresolved library deps ==="
# Look at the binaries and search for dynamic library dependencies that are not included on every system
# So far, this finds only liblzma but in the future it may be necessary for more libs
for binary in "helper" "Fedora Media Writer"; do
otool -L "app/Fedora Media Writer.app/Contents/MacOS/$binary" |\
grep -E "^\s" | grep -Ev "Foundation|OpenGL|AGL|DiskArbitration|IOKit|libc\+\+|libobjc|libSystem|@rpath" |\
sed -e 's/[[:space:]]\([^[:space:]]*\).*/\1/' |\
while read library; do
if [[ ! $library == @loader_path/* ]]; then
echo "Copying $(basename $library)"
cp $library "app/Fedora Media Writer.app/Contents/Frameworks"
install_name_tool -change "$library" "@executable_path/../Frameworks/$(basename ${library})" "app/Fedora Media Writer.app/Contents/MacOS/$binary"
fi
done
done
done
popd >/dev/null
}

echo "=== Signing the package ==="
# sign all frameworks and then the package
find app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do
codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime
done
codesign -s "$DEVELOPER_ID" --deep -v -f app/Fedora\ Media\ Writer.app/ -o runtime
function sign() {
pushd build >/dev/null
echo "=== Signing the package ==="
# sign all frameworks and then the package
find app/Fedora\ Media\ Writer.app -name "*framework" | while read framework; do
codesign -s "$DEVELOPER_ID" --deep -v -f "$framework/Versions/Current/" -o runtime
done
codesign -s "$DEVELOPER_ID" --deep -v -f app/Fedora\ Media\ Writer.app/ -o runtime
popd >/dev/null
}

echo "=== Creating a disk image ==="
# create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting)
rm -f ../FedoraMediaWriter-osx-$(git describe --tags).dmg
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
function dmg() {
pushd build >/dev/null
echo "=== Creating a disk image ==="
# create the .dmg package - beware, it won't work while FMW is running (blocks partition mounting)
rm -f "../FedoraMediaWriter-osx-$VERSION.dmg"
hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.unnotarized.dmg
popd >/dev/null
}

echo "=== Submitting for notarization ==="
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"
function notarize() {
echo "=== Submitting for notarization ==="
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"

echo "DONE. After notarization finished (you'll get an email), run:"
echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app"
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"
echo "DONE. After notarization finished (you'll get an email), run:"
echo "$ xcrun stabler stable app/Fedora\ Media\ Writer.app"
echo "$ hdiutil create -srcfolder app/Fedora\ Media\ Writer.app -format UDCO -imagekey zlib-level=9 -scrub -volname FedoraMediaWriter-osx ../FedoraMediaWriter-osx-$VERSION.dmg"
}

popd >/dev/null
if [[ $# -eq 0 ]]; then
configure
build
deps
sign
dmg
notarize
else
$1
fi
Loading

0 comments on commit 9f796e6

Please sign in to comment.