Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS x64 build fixes and updates #211

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,30 @@ jobs:
with:
fetch-depth: 0

- name: Change version for non-release
if: github.ref_name != 'main'
run: |
VERSION=$(grep "set(VERSION" CMakeLists.txt | cut -d '"' -f 2)
NEW_VERSION="$VERSION-testing-$(date '+%Y%m%d')"
echo NEW_VERSION=$NEW_VERSION >> $GITHUB_ENV

- name: Build
run: |
bash osx/build-nzbget-x64.sh
if [ "$GITHUB_REF_NAME" != "main" ]; then
bash osx/build-nzbget-x64.sh testing
else
bash osx/build-nzbget-x64.sh
fi

- name: Rename build artifacts
if: github.ref_name != 'main' && github.ref_name != 'develop'
run: |
cd tmp
NEW_VERSION_FEATURE="$NEW_VERSION-${GITHUB_REF_NAME/\//-}"
cd build
SUFFIX="${GITHUB_REF_NAME/\//-}"
for FILE in *.zip; do
[ -f $FILE ] || continue
NEW_FILE=${FILE/$NEW_VERSION/$NEW_VERSION_FEATURE}
NEW_FILE=${FILE/-bin-macos-x64.zip/-$SUFFIX-bin-macos-x64.zip}
mv $FILE $NEW_FILE
done

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nzbget-osx-installers-x64
path: tmp/*.zip
path: build/*.zip
retention-days: 5

build-universal:
Expand Down
7 changes: 4 additions & 3 deletions osx/build-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ xcode-select --install
### Building NZBGet
From cloned repository run
```
bash osx/build-nzbget-x64.sh
bash osx/build-nzbget-x64.sh [testing]
```
- `testing` - build testing package (add VersionSuffix=`-testing-$yyyyMMdd` to package version)

### Output files
- tmp/osx/build/Release/NZBGet.app - application
- tmp/nzbget-$VERSION-bin-macos-x64.zip - release archive
- build/nzbget/osx/build/Release/NZBGet.app - application
- build/nzbget-$VERSION-bin-macos-x64.zip - release archive
37 changes: 20 additions & 17 deletions osx/build-nzbget-x64.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

# strict error handling for debugging
set -o nounset
set -o errexit

# config variables
Expand All @@ -15,34 +16,36 @@ JOBS=$(sysctl -n hw.ncpu)

# create directories and cleanup
mkdir -p build
mkdir -p tmp
rm -rf build/*
rm -rf tmp/*
NZBGET_PATH=build/nzbget
BUILD_PATH=build/release64
mkdir $NZBGET_PATH
mkdir $BUILD_PATH

export LIBS="-liconv -lncurses $LIB_PATH/libboost_json.a $LIB_PATH/libxml2.a $LIB_PATH/libz.a $LIB_PATH/libssl.a $LIB_PATH/libcrypto.a $LIB_PATH/liblzma.a"
export INCLUDES="$INCLUDE_PATH/;$INCLUDE_PATH/libxml2/"
VERSION=$(grep "set(VERSION" CMakeLists.txt | cut -d '"' -f 2)
VERSION=$(grep "set(VERSION " CMakeLists.txt | cut -d '"' -f 2)
VERSION_SUFFIX=""
if [ $# -gt 0 ]; then
if [ "$1" == "testing" ]; then
VERSION_SUFFIX="-testing-$(date '+%Y%m%d')"
fi
fi

# copy macOS project to tmp
cp -r osx tmp/
# copy macOS project to package
cp -r osx "$NZBGET_PATH/"
DAEMON_PATH=osx/Resources/daemon/usr/local

# make static daemon binary
cd build
cmake .. -DENABLE_STATIC=ON -DCMAKE_INSTALL_PREFIX="$PWD/../tmp/$DAEMON_PATH"
# if running from CI/CD, add testing to builds from non-main branch
if [ -n "$GITHUB_REF_NAME" ]; then
if [ "$GITHUB_REF_NAME" != "main" ]; then
VERSION="$VERSION-testing-$(date '+%Y%m%d')"
sed -e "s|#define VERSION.*|#define VERSION \"$VERSION\"|g" -i '' config.h
fi
fi
cd $BUILD_PATH
cmake ../.. -DENABLE_STATIC=ON -DCMAKE_INSTALL_PREFIX="$PWD/../../$NZBGET_PATH/$DAEMON_PATH" -DVERSION_SUFFIX="$VERSION_SUFFIX"
cmake --build . -j $JOBS
strip nzbget
cmake --install .
cd ../..

# fetch tools and root certificates
cd ../tmp
cd $NZBGET_PATH
mkdir -p $DAEMON_PATH/bin
rm -rf $DAEMON_PATH/etc

Expand Down Expand Up @@ -87,6 +90,6 @@ sed -i '' 's:^SevenZipCmd=.*:SevenZipCmd=${AppDir}/7za:' $CONF_FILE
xcodebuild -project osx/NZBGet.xcodeproj -configuration "Release" -destination "platform=macOS" build

# create build archive
ARCHIVE_NAME=nzbget-$VERSION-bin-macos-x64.zip
ARCHIVE_NAME=nzbget-$VERSION$VERSION_SUFFIX-bin-macos-x64.zip
(cd osx/build/Release/ && zip -r $ARCHIVE_NAME NZBGet.app)
mv osx/build/Release/$ARCHIVE_NAME .
mv osx/build/Release/$ARCHIVE_NAME ..