Skip to content

Update build_app.yaml #177

Update build_app.yaml

Update build_app.yaml #177

Workflow file for this run

name: Build app
on:
push:
tags:
- "v*.*.*"
env:
librescore_b_name: ${{ secrets.LIBRESCORE_B_NAME }}
jobs:
release:
runs-on: ubuntu-latest
outputs:
output: ${{ steps.get_latest_release.outputs.updated }}
steps:
- name: Get latest release
id: get_latest_release
run: |
echo "updated=true" >> "$GITHUB_ENV"
if [[ "${{ github.ref_name }}" == "$(curl -s -u ${{ secrets.LIBRESCORE_USERNAME }}:${{ secrets.LIBRESCORE_TOKEN }} -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/latest | jq --raw-output ".tag_name")" ]]; then
echo "updated=false" >> "$GITHUB_ENV"
exit 1
fi
- name: Publish pre-release
if: ${{ steps.get_latest_release.outputs.updated }} == 'true'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.LIBRESCORE_TOKEN }}
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_A }}
body: '## Download
| <img src="https://upload.wikimedia.org/wikipedia/commons/e/e2/Windows_logo_and_wordmark_-_2021.svg" width="512"> | <img src="https://upload.wikimedia.org/wikipedia/commons/2/21/MacOS_wordmark_%282017%29.svg" width="512"> | <img src="https://upload.wikimedia.org/wikipedia/commons/3/35/Tux.svg" width="512"> | <img src="https://upload.wikimedia.org/wikipedia/commons/3/31/Android_robot_head.svg" width="512"> |
| :---: | :---: | :---: | :---: |
| Windows (7+) (64-bit only) | macOS (10.11+) (Rosetta 2) | Linux (64-bit only) | Android (6.0+) |
| [Download (EXE)](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/download/${{ github.ref_name }}/LibreScore.exe) | [Download (DMG)](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/download/${{ github.ref_name }}/LibreScore.dmg) | [Download (AppImage)](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/download/${{ github.ref_name }}/LibreScore.AppImage) | [Download (APK)](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/download/${{ github.ref_name }}/LibreScore.apk) |
### Having trouble?
Installation instructions are in the [README](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/blob/master/README.md) file.'
build:
needs: release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: true
steps:
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.22.x"
channel: "stable"
cache: true
cache-key: flutter
cache-path: ${{ runner.tool_cache }}/flutter
- run: git config --global url."https://".insteadOf git://
- uses: actions/checkout@v3
with:
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_A }}
token: ${{ secrets.LIBRESCORE_TOKEN }}
submodules: 'recursive'
- name: Import GPG key
if: matrix.os == 'ubuntu-latest'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.LIBRESCORE_GPG }}
passphrase: ${{ secrets.LIBRESCORE_GPG_PASSWORD }}
- name: Build AppImage
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update -y
sudo apt install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev fuse libfuse2
flutter config --enable-linux-desktop
flutter clean
flutter build linux --obfuscate --split-debug-info=./build/app/outputs/symbols
patchelf --set-interpreter ./ld-linux-x86-64.so.2 ./build/linux/x64/release/bundle/librescore
ldd ./build/linux/x64/release/bundle/librescore | awk -F '=> ' 'NF>1{ sub(/ .*/,"",$NF); system("cp " $NF " ./build/linux/x64/release/bundle/lib/") }'
cp $(ldconfig -p | grep "librt\.." | awk -F '=> ' 'NF>1{ sub(/ .*/,"",$NF); print $NF }' | head -n 1) ./build/linux/x64/release/bundle/lib/
patchelf --add-needed librt.so.1 ./build/linux/x64/release/bundle/librescore
LD_LIBRARY_PATH=$LD_LIBRARY_PATH./build/linux/x64/release/bundle/lib ldd ./build/linux/x64/release/bundle/librescore | awk -F '=> ' 'NF>1{ sub(/ .*/,"",$NF); system("patchelf " $NF " --set-rpath \"\\$ORIGIN\"") }'
cp -R ./build/linux/x64/release/bundle/* ./installer/AppImage/
chmod a+x ./appimagetool.AppImage
ARCH=x86_64 ./appimagetool.AppImage ./installer/AppImage --no-appstream --sign
mv ./LibreScore-x86_64.AppImage ./LibreScore.AppImage
- name: Upload AppImage
if: matrix.os == 'ubuntu-latest'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.LIBRESCORE_TOKEN }}
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_A }}
files: |
./LibreScore.AppImage
- uses: actions/setup-java@v3
if: matrix.os == 'ubuntu-latest'
with:
distribution: "zulu"
java-version: "17"
cache: "gradle"
- name: Build APK
if: matrix.os == 'ubuntu-latest'
run: |
echo "${{ secrets.UPLOAD_KEYSTORE_JKS_A }}" | base64 --decode > ./android/upload-keystore.jks
echo "storePassword=${{ secrets.KEYSTORE_STORE_PASSWORD_A }}" > ./android/key.properties
echo "keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD_A }}" >> ./android/key.properties
echo "keyAlias=upload" >> ./android/key.properties
echo "storeFile=../upload-keystore.jks" >> ./android/key.properties
flutter clean
flutter build apk --obfuscate --split-debug-info=./build/app/outputs/symbols
mv ./build/app/outputs/flutter-apk/app-release.apk ./LibreScore.apk
flutter build apk --split-per-abi --obfuscate --split-debug-info=./build/app/outputs/symbols
mv ./build/app/outputs/flutter-apk/app-arm64-v8a-release.apk ./LibreScore-arm64-v8a.apk
mv ./build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk ./LibreScore-armeabi-v7a.apk
mv ./build/app/outputs/flutter-apk/app-x86_64-release.apk ./LibreScore-x86_64.apk
- name: Upload APK
if: matrix.os == 'ubuntu-latest'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.LIBRESCORE_TOKEN }}
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_A }}
files: |
./LibreScore.apk
./LibreScore-arm64-v8a.apk
./LibreScore-armeabi-v7a.apk
./LibreScore-x86_64.apk
- uses: actions/checkout@v3
if: matrix.os == 'ubuntu-latest'
with:
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_B }}
token: ${{ secrets.LIBRESCORE_TOKEN }}
submodules: 'recursive'
- name: Build APK
if: matrix.os == 'ubuntu-latest'
run: |
echo "${{ secrets.UPLOAD_KEYSTORE_JKS_B }}" | base64 --decode > ./android/upload-keystore.jks
echo "storePassword=${{ secrets.KEYSTORE_STORE_PASSWORD_B }}" > ./android/key.properties
echo "keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD_B }}" >> ./android/key.properties
echo "keyAlias=upload" >> ./android/key.properties
echo "storeFile=../upload-keystore.jks" >> ./android/key.properties
flutter clean
flutter build apk --obfuscate --split-debug-info=./build/app/outputs/symbols
mv ./build/app/outputs/flutter-apk/app-release.apk ./${{ secrets.LIBRESCORE_B_NAME }}.apk
flutter build apk --split-per-abi --obfuscate --split-debug-info=./build/app/outputs/symbols
mv ./build/app/outputs/flutter-apk/app-arm64-v8a-release.apk ./${{ secrets.LIBRESCORE_B_NAME }}-arm64-v8a.apk
mv ./build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk ./${{ secrets.LIBRESCORE_B_NAME }}-armeabi-v7a.apk
mv ./build/app/outputs/flutter-apk/app-x86_64-release.apk ./${{ secrets.LIBRESCORE_B_NAME }}-x86_64.apk
./meta.sh &>/dev/null
- name: Upload APK
if: matrix.os == 'ubuntu-latest'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.LIBRESCORE_TOKEN }}
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_B }}
body: '## Download
| <img src="https://upload.wikimedia.org/wikipedia/commons/3/31/Android_robot_head.svg" width="256"> |
| :---: |
| Android (6.0+) |
| [Download (APK)](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_B }}/releases/download/${{ github.ref_name }}/${{ secrets.LIBRESCORE_B_NAME }}.apk) |
### Having trouble?
Installation instructions are in the [README](https://github.com/LibreScore/${{ secrets.LIBRESCORE_REPO_B }}/blob/master/README.md) file.'
files: |
./${{ secrets.LIBRESCORE_B_NAME }}.apk
./${{ secrets.LIBRESCORE_B_NAME }}-arm64-v8a.apk
./${{ secrets.LIBRESCORE_B_NAME }}-armeabi-v7a.apk
./${{ secrets.LIBRESCORE_B_NAME }}-x86_64.apk
- name: Build EXE
if: matrix.os == 'windows-latest'
run: |
flutter clean
flutter build windows --obfuscate --split-debug-info=.\build\app\outputs\symbols
"${{ secrets.LIBRESCORE_PFX }}" > .\installer\LibreScore.pfx.base64
certutil -decode .\installer\LibreScore.pfx.base64 .\installer\LibreScore.pfx
& "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe" sign /f .\installer\LibreScore.pfx /p ${{ secrets.LIBRESCORE_PFX_PASSWORD }} /tr http://timestamp.sectigo.com/ /fd SHA256 /td SHA256 .\build\windows\x64\runner\Release\librescore.exe
Get-ChildItem -Path .\build\windows\x64\runner\Release -File | Where {($_.Extension -ne ".dll" -and $_.Extension -ne ".exe")} | Remove-Item
Copy-Item (& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') .\build\windows\x64\runner\Release
Copy-Item (& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') .\build\windows\x64\runner\Release
Copy-Item (& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') .\build\windows\x64\runner\Release
dart run msix:create
& "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe" sign /f .\installer\LibreScore.pfx /p ${{ secrets.LIBRESCORE_PFX_PASSWORD }} /tr http://timestamp.sectigo.com/ /fd SHA256 /td SHA256 .\installer\LibreScore.msix
Start-Process iexpress -ArgumentList /N,.\installer\MSIX\LibreScoreMsix.sed -NoNewWindow -Wait
& "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe" sign /f .\installer\LibreScore.pfx /p ${{ secrets.LIBRESCORE_PFX_PASSWORD }} /tr http://timestamp.sectigo.com/ /fd SHA256 /td SHA256 .\installer\LibreScoreMsix.exe
Copy-Item -Path .\build\windows\x64\runner\Release -Destination .\installer\Inno\LibreScore -Recurse
New-Item -Name .\installer\Inno\LibreScore\data\flutter_assets\assets\.inno
iscc .\installer\Inno\LibreScore.iss
& "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe" sign /f .\installer\LibreScore.pfx /p ${{ secrets.LIBRESCORE_PFX_PASSWORD }} /tr http://timestamp.sectigo.com/ /fd SHA256 /td SHA256 .\installer\LibreScoreInno.exe
Start-Process iexpress -ArgumentList /N,.\installer\LibreScore.sed -NoNewWindow -Wait
& "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe" sign /f .\installer\LibreScore.pfx /p ${{ secrets.LIBRESCORE_PFX_PASSWORD }} /tr http://timestamp.sectigo.com/ /fd SHA256 /td SHA256 .\installer\LibreScore.exe
Compress-Archive -Path .\build\windows\x64\runner\Release\* -DestinationPath .\installer\LibreScore.zip
- name: Upload EXE
if: matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.LIBRESCORE_TOKEN }}
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_A }}
files: |
./installer/LibreScoreMsix.exe
./installer/LibreScoreInno.exe
./installer/LibreScore.exe
./installer/LibreScore.zip
- name: Build DMG
if: matrix.os == 'macos-latest'
run: |
flutter clean
flutter build macos --obfuscate --split-debug-info=build/app/outputs/symbols
hdiutil create -type SPARSEBUNDLE -size 97656.25k LibreScore
hdiutil attach ./LibreScore.sparsebundle
ln -s /Applications /Volumes/untitled
cp -R build/macos/Build/Products/Release/LibreScore.app /Volumes/untitled/
cp ./ds /Volumes/untitled/.DS_Store
hdiutil detach /Volumes/untitled
hdiutil convert -format UDRO -o LibreScore.dmg LibreScore.sparsebundle/
chmod 755 macos/Scripts/postinstall
pkgbuild --install-location /Applications --component ./build/macos/Build/Products/Release/LibreScore.app --scripts ./macos/Scripts ./LibreScore.pkg
- name: Upload DMG
if: matrix.os == 'macos-latest'
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.LIBRESCORE_TOKEN }}
repository: LibreScore/${{ secrets.LIBRESCORE_REPO_A }}
files: |
./LibreScore.dmg
./LibreScore.pkg
delete:
needs: [release, build]
if: always() && contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
steps:
- name: Delete pre-release
if: ${{needs.release.outputs.updated}} == 'true'
run: |
ID_A="$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.LIBRESCORE_TOKEN }}" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/tags/${{ github.ref_name }} | jq -r .id)"
curl -s -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.LIBRESCORE_TOKEN }}" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/releases/$ID_A
curl -s -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.LIBRESCORE_TOKEN }}" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_A }}/git/refs/tags/${{ github.ref_name }}
ID_B="$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.LIBRESCORE_TOKEN }}" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_B }}/releases/tags/${{ github.ref_name }} | jq -r .id)"
curl -s -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.LIBRESCORE_TOKEN }}" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_B }}/releases/$ID_B
curl -s -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.LIBRESCORE_TOKEN }}" https://api.github.com/repos/LibreScore/${{ secrets.LIBRESCORE_REPO_B }}/git/refs/tags/${{ github.ref_name }}
- name: Delete workflow run
if: ${{needs.release.outputs.updated}} == 'false'
run: |
curl -s -i -u ${{ secrets.LIBRESCORE_USERNAME }}:${{ secrets.LIBRESCORE_TOKEN }} -d '{"event_type":"delete_action","client_payload":{"run_id":"'"${{ github.run_id }}"'","repo":"LibreScore/app-librescore"}}' -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/LibreScore/actions/dispatches