@@ -182,8 +182,124 @@ jobs:
182182 cli/*.apk
183183 retention-days : 30
184184
185+ build-and-package-macos :
186+ runs-on : ${{ matrix.os }}
187+ strategy :
188+ matrix :
189+ os : [macos-13, macos-14]
190+
191+ steps :
192+ - name : Checkout code
193+ uses : actions/checkout@v4
194+ with :
195+ fetch-depth : 0
196+ ssh-key : ${{ secrets.DEPLOY_KEY }}
197+
198+ - name : Set up Python
199+ uses : actions/setup-python@v4
200+ with :
201+ python-version : " 3.11"
202+
203+ - name : Install Poetry
204+ uses : snok/install-poetry@v1
205+ with :
206+ version : latest
207+ virtualenvs-create : true
208+ virtualenvs-in-project : true
209+
210+ - name : Cache dependencies
211+ uses : actions/cache@v3
212+ with :
213+ path : cli/.venv
214+ key : venv-${{ matrix.os }}-${{ hashFiles('cli/poetry.lock') }}
215+
216+ - name : Install dependencies
217+ working-directory : cli
218+ run : poetry install
219+
220+ - name : Extract version from pyproject.toml
221+ id : version
222+ working-directory : cli
223+ run : |
224+ VERSION=$(poetry version --short)
225+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
226+ echo "Extracted version: $VERSION"
227+
228+ - name : Install fpm
229+ run : |
230+ sudo gem install --no-document fpm
231+
232+ - name : Build CLI binary
233+ working-directory : cli
234+ env :
235+ NIXOPUS_DISABLE_DOCKER : " 1"
236+ run : |
237+ chmod +x build.sh
238+ if [ ! -d "helpers" ]; then
239+ ln -s ../helpers helpers
240+ fi
241+ echo "Running production build (PyInstaller)"
242+ ./build.sh --no-test --no-cleanup --no-archive
243+
244+ - name : Prepare binary for packaging
245+ working-directory : cli
246+ run : |
247+ mkdir -p packaging/usr/local/bin
248+ if [ -f "dist/nixopus" ]; then
249+ cp dist/nixopus packaging/usr/local/bin/
250+ if [ -d "dist/nixopus_darwin_amd64" ]; then
251+ cp -r dist/nixopus_darwin_amd64 packaging/usr/local/bin/
252+ elif [ -d "dist/nixopus_darwin_arm64" ]; then
253+ cp -r dist/nixopus_darwin_arm64 packaging/usr/local/bin/
254+ fi
255+ else
256+ echo "Build output not found in expected location"
257+ ls -la dist/
258+ exit 1
259+ fi
260+ chmod +x packaging/usr/local/bin/nixopus
261+
262+ - name : Set architecture variables
263+ run : |
264+ ARCH=$(uname -m)
265+ case "$ARCH" in
266+ x86_64) PKG_ARCH=amd64 ;;
267+ aarch64|arm64) PKG_ARCH=arm64 ;;
268+ *) PKG_ARCH=$ARCH ;;
269+ esac
270+ echo "ARCH=$ARCH" >> $GITHUB_ENV
271+ echo "PKG_ARCH=$PKG_ARCH" >> $GITHUB_ENV
272+
273+ - name : Create PKG package
274+ working-directory : cli
275+ run : |
276+ VERSION="${{ steps.version.outputs.VERSION }}"
277+ fpm -s dir -t osxpkg \
278+ -n nixopus \
279+ -v "$VERSION" \
280+ -a "$PKG_ARCH" \
281+ --description "A CLI for Nixopus" \
282+ --maintainer "Nixopus <raghavyuva@gmail.com>" \
283+ --license "FSL" \
284+ --url "https://github.com/nixopus/cli" \
285+ --prefix / \
286+ packaging/=/
287+ PKG_SOURCE="nixopus-${VERSION}.pkg"
288+ PKG_TARGET="nixopus-${VERSION}-darwin-$PKG_ARCH.pkg"
289+ mv "$PKG_SOURCE" "$PKG_TARGET"
290+
291+ - name : Upload artifacts
292+ uses : actions/upload-artifact@v4
293+ with :
294+ name : nixopus-packages-${{ matrix.os }}-${{ env.ARCH }}
295+ path : |
296+ cli/*.pkg
297+ retention-days : 30
298+
185299 create-release :
186- needs : build-and-package
300+ needs :
301+ - build-and-package
302+ - build-and-package-macos
187303 runs-on : ubuntu-22.04
188304 permissions :
189305 contents : write
@@ -212,7 +328,7 @@ jobs:
212328 while IFS= read -r -d '' file; do
213329 filename=$(basename "$file")
214330 PACKAGE_FILES+=("$filename")
215- done < <(find ./artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.tar" -o -name "*.apk" \) -print0)
331+ done < <(find ./artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.tar" -o -name "*.apk" -o -name "*.pkg" \) -print0)
216332
217333 echo "Found package files: ${PACKAGE_FILES[@]}"
218334
@@ -256,14 +372,14 @@ jobs:
256372
257373 echo "Creating release with tag: $RELEASE_TAG"
258374 echo "Files to upload:"
259- find ./artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.tar" -o -name "*.apk" \) -exec ls -la {} \;
375+ find ./artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.tar" -o -name "*.apk" -o -name "*.pkg" \) -exec ls -la {} \;
260376
261377 gh release create "$RELEASE_TAG" \
262378 --title "Nixopus CLI v$CLI_VERSION" \
263379 --notes "Nixopus CLI v$CLI_VERSION - Packages: DEB, RPM, TAR, APK for x86_64 and ARM64" \
264380 --target ${{ github.ref_name }} \
265381 --prerelease
266382
267- find ./artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.tar" -o -name "*.apk" \) -exec gh release upload "$RELEASE_TAG" {} \;
383+ find ./artifacts -type f \( -name "*.deb" -o -name "*.rpm" -o -name "*.tar" -o -name "*.apk" -o -name "*.pkg" \) -exec gh release upload "$RELEASE_TAG" {} \;
268384 env :
269385 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments