ADD: Release workflow (macOS)

(cherry picked from commit c6f455c676)
This commit is contained in:
Alexander Koblov 2023-08-02 20:07:23 +03:00
commit 5b87675ab1
2 changed files with 131 additions and 0 deletions

76
.github/scripts/create_release.sh vendored Executable file
View file

@ -0,0 +1,76 @@
#!/bin/bash
# The new package will be saved here
PACK_DIR=$PWD/doublecmd-release
# Temp dir for creating *.dmg package
BUILD_PACK_DIR=/var/tmp/doublecmd-$(date +%y.%m.%d)
# Save revision number
DC_REVISION=$(install/linux/update-revision.sh ./ ./)
# Read version number
DC_MAJOR=$(grep 'MajorVersionNr' src/doublecmd.lpi | grep -o '[0-9.]\+')
DC_MINOR=$(grep 'MinorVersionNr' src/doublecmd.lpi | grep -o '[0-9.]\+')
DC_MICRO=$(grep 'RevisionNr' src/doublecmd.lpi | grep -o '[0-9.]\+' || echo 0)
DC_VER=$DC_MAJOR.$DC_MINOR.$DC_MICRO
# Set widgetset
export lcl=cocoa
mkdir -p $PACK_DIR
# Update application bundle version
defaults write $(pwd)/doublecmd.app/Contents/Info CFBundleVersion $DC_REVISION
defaults write $(pwd)/doublecmd.app/Contents/Info CFBundleShortVersionString $DC_VER
plutil -convert xml1 $(pwd)/doublecmd.app/Contents/Info.plist
build_unrar()
{
DEST_DIR=$(pwd)/install/darwin/lib/$CPU_TARGET
pushd /tmp/unrar
make clean lib CXXFLAGS+="-std=c++14 -DSILENT --target=$TARGET" LDFLAGS+="-dylib --target=$TARGET"
mkdir -p $DEST_DIR && mv libunrar.so $DEST_DIR/libunrar.dylib
popd
}
build_doublecmd()
{
# Build all components of Double Commander
./build.sh release
# Copy libraries
cp -a install/darwin/lib/$CPU_TARGET/*.dylib ./
# Create *.dmg package
mkdir -p $BUILD_PACK_DIR
install/darwin/install.sh $BUILD_PACK_DIR
pushd $BUILD_PACK_DIR
mv doublecmd.app 'Double Commander.app'
codesign --deep --force --verify --verbose --sign '-' 'Double Commander.app'
hdiutil create -anyowners -volname "Double Commander" -imagekey zlib-level=9 -format UDZO -fs HFS+ -srcfolder 'Double Commander.app' $PACK_DIR/doublecmd-$DC_VER-$DC_REVISION.$lcl.$CPU_TARGET.dmg
popd
# Clean DC build dir
./clean.sh
rm -f *.dylib
rm -rf $BUILD_PACK_DIR
}
# Set processor architecture
export CPU_TARGET=aarch64
export TARGET=arm64-apple-darwin
# Set minimal Mac OS X target version
export MACOSX_DEPLOYMENT_TARGET=11.0
build_unrar
build_doublecmd
# Set processor architecture
export CPU_TARGET=x86_64
export TARGET=x86_64-apple-darwin
# Set minimal Mac OS X target version
export MACOSX_DEPLOYMENT_TARGET=10.11
build_unrar
build_doublecmd

55
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: build-release
on:
workflow_dispatch:
release:
types: [prereleased, released]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build-mac:
runs-on: macos-11
steps:
- name: Install Free Pascal
uses: alexx2000/setup-fpc@master
with:
lazarus-version: "stable"
- name: Get Lazarus source
uses: actions/checkout@v3
with:
repository: 'fpc/Lazarus'
- name: Build and install Lazarus
run: make all install
- name: Create Lazarus config
run: |
sudo mkdir -p /etc/lazarus
sudo cp tools/install/macosx/environmentoptions.xml /etc/lazarus/environmentoptions.xml
sudo sed -i -e "s|_PPCARCH_|fpc|g; s|/Developer/lazarus|/usr/local/share/lazarus|g" /etc/lazarus/environmentoptions.xml
- name: Checkout source
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download unrar source code
run: wget https://www.rarlab.com/rar/unrarsrc-6.2.10.tar.gz -O /tmp/unrarsrc.tar.gz
- name: Extract unrar source code
run: cd /tmp && tar xzf unrarsrc.tar.gz
- name: Build packages
run: ./.github/scripts/create_release.sh
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
file: doublecmd-release/doublecmd*.dmg
tag: ${{ github.ref }}
overwrite: true
file_glob: true