From 54049cb16d8d1cb50be2fe148e0cce1c9c5ee512 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 16 Jun 2022 16:55:16 -0400 Subject: [PATCH] Lint and built Portfile --- .github/workflows/CI.yml | 275 +++++++++++++++++++++++++-------------- 1 file changed, 178 insertions(+), 97 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 18d7e89cc13..02fc3ccc5e0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -340,103 +340,184 @@ jobs: last_version: ${{ needs.check_changelog.outputs.last_version }} release_body: ${{ needs.check_changelog.outputs.release_body }} -# build_mac_port: -# name: Macports -# runs-on: macos-11 -# needs: [check_changelog, build_mac] -# -# steps: -# - name: Cache Artifacts -# uses: actions/cache@v3 -# with: -# path: artifacts -# key: ${{ runner.os }}-artifacts -# -# - name: Setup Macports -# run : | -# # update paths for macports -# echo "/opt/local/sbin" >> $GITHUB_PATH -# echo "/opt/local/bin" >> $GITHUB_PATH -# -# # Set OpenSSL 1.1 as default -# # rm -rf /usr/local/opt/openssl -# # rm -rf /usr/local/bin/openssl -# # ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/bin/openssl /usr/local/bin/openssl -# # ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o /usr/local/opt/openssl -# -# # download and extract macports -# curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.7.2.tar.bz2 -# tar xf MacPorts-2.7.2.tar.bz2 -# -# # build macports -# cd MacPorts-2.7.2 -# ./configure -# make -# sudo make install -# cd ../ -# rm -rf MacPorts-2.7.2* -# -# - name: Configure Macports -# run: | -# # update sources -# sudo port -v selfupdate -# -# # use custom sources -# sudo chmod 777 /opt/local/etc/macports/sources.conf -# echo file://$(echo ~)/ports > /opt/local/etc/macports/sources.conf -# echo rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default] >> /opt/local/etc/macports/sources.conf -# sudo chmod 644 /opt/local/etc/macports/sources.conf -# -# # setup custom port -# mkdir -p ~/ports/multimedia/sunshine -# -# # copy configured Portfile -# mv ./artifacts/Portfile ~/ports/multimedia/sunshine/ -# -# # remove remaining cached artifacts -# rm -r -f ./artifacts -# mkdir artifacts -# -# # index the ports -# cd ~/ports -# portindex -# -# - name: Build -# run: | -# # build port -# sudo port install sunshine \ -# || cat /opt/local/var/macports/logs/_Users_runner_ports_multimedia_sunshine/Sunshine/main.log \ -# && exit 1 -# -# # create packages -# sudo port dmg sunshine -# sudo port pkg sunshine -# -# # move -# mv $(port work sunshine)/Sunshine*.dmg ./artifacts/sunshine.dmg -# mv $(port work sunshine)/Sunshine*.ppkg ./artifacts/sunshine.pkg -# -# # testing only -# # ls ~/ports/multimedia/sunshine -# # cat ~/ports/multimedia/sunshine/Portfile -# # cat /opt/local/etc/macports/sources.conf -# # cat ~/ports/Portindex -# # port search sunshine -# -# - name: Upload Artifacts -# uses: actions/upload-artifact@v3 -# with: -# name: sunshine-macports -# path: artifacts/ -# -# - name: Create Release -# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} -# uses: SunshineStream/actions/create_release@master -# with: -# token: ${{ secrets.GITHUB_TOKEN }} -# next_version: ${{ needs.check_changelog.outputs.next_version }} -# last_version: ${{ needs.check_changelog.outputs.last_version }} -# release_body: ${{ needs.check_changelog.outputs.release_body }} + build_mac_port: + name: Macports + needs: [check_changelog, build_mac] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ macos-10.15, macos-11, macos-12 ] + + steps: + - name: Cache Artifacts + uses: actions/cache@v3 + with: + path: artifacts + key: ${{ runner.os }}-artifacts + + - name: Checkout ports + uses: actions/checkout@v3 + with: + repository: macports/macports-ports + fetch-depth: 64 + path: ports + + - name: Checkout mpbb + uses: actions/checkout@v3 + with: + repository: macports/mpbb + path: mpbb + + - name: Bootstrap MacPorts + run: | + . ports/.github/workflows/bootstrap.sh + + - name: Setup Macports + run : | + # Add getopt, mpbb and the MacPorts paths to $PATH for the subsequent steps. + echo "/opt/mports/bin" >> $GITHUB_PATH + echo "${PWD}/mpbb" >> $GITHUB_PATH + echo "/opt/local/bin" >> $GITHUB_PATH + echo "/opt/local/sbin" >> $GITHUB_PATH + + # copy Portfile from artifacts to ports + mkdir -p ./ports/multimedia/Sunshine + cp -f ./artifacts/Portfile ./ports/multimedia/Sunshine/Portfile + + - name: Determine list of subports + id: subportlist + run: | + set -eu + subportlist="" + + echo "Listing subports for Sunshine" + new_subports=$(mpbb \ + --work-dir /tmp/mpbb \ + list-subports \ + --archive-site= \ + --archive-site-private= \ + --include-deps=no \ + "$port" \ + | tr '\n' ' ') + for subport in $new_subports; do + echo "$subport" + subportlist="$subportlist $subport" + done + echo "::set-output name=subportlist::${subportlist}" + + - name: Run port lint for all subports + run: | + set -eu + fail=0 + for subport in $subportlist; do + echo "::group::${subport}" + path=$(port file "$subport") + messagetype="warning" + if ! messages=$(port -q lint "$subport" 2>&1); then + messagetype="error" + fail=1 + fi + if [ -n "$messages" ]; then + echo "$messages" + # See https://github.com/actions/toolkit/issues/193#issuecomment-605394935 + encoded_messages="port lint ${subport}:%0A" + encoded_messages+="$(echo "${messages}" | sed -E 's/$/%0A/g' | tr -d '\n')" + echo "::${messagetype} file=${path#${PWD}/ports/},line=1,col=1::${encoded_messages}" + fi + echo "::endgroup::" + done + exit "$fail" + env: + subportlist: ${{ steps.subportlist.outputs.subportlist }} + + - name: Build subports + run: | + set -eu + fail=0 + for subport in $subportlist; do + workdir="/tmp/mpbb/$subport" + mkdir -p "$workdir/logs" + touch "$workdir/logs/dependencies-progress.txt" + echo "::group::Cleaning up between ports" + sudo mpbb --work-dir "$workdir" cleanup + echo "::endgroup::" + echo "::group::Installing dependencies for ${subport}" + sudo mpbb \ + --work-dir "$workdir" \ + install-dependencies \ + "$subport" >"$workdir/logs/install-dependencies.log" 2>&1 & + deps_pid=$! + tail -f "$workdir/logs/dependencies-progress.txt" 2>/dev/null & + tail_pid=$! + set +e + wait "$deps_pid" + deps_exit=$? + set -e + kill "$tail_pid" || true + if [ "$deps_exit" -ne 0 ]; then + echo "::endgroup::" + echo "::error::Failed to install dependencies for ${subport}" + fail=1 + continue + fi + echo "::endgroup::" + echo "::group::Installing ${subport}" + set +e + sudo mpbb \ + --work-dir "$workdir" \ + install-port \ + --source \ + "$subport" + install_exit=$? + set -e + if [ "$install_exit" -ne 0 ]; then + echo "::endgroup::" + echo "::error::Failed to install ${subport}" + fail=1 + continue + fi + echo "::endgroup::" + done + exit "$fail" + env: + subportlist: ${{ steps.subportlist.outputs.subportlist }} + + - name: Package + run: | + # build port + # sudo port install sunshine \ + # || cat /opt/local/var/macports/logs/_Users_runner_ports_multimedia_sunshine/Sunshine/main.log \ + # && exit 1 + + # create packages + sudo port dmg sunshine + sudo port pkg sunshine + + # move + mv $(port work sunshine)/Sunshine*.dmg ./artifacts/sunshine.dmg + mv $(port work sunshine)/Sunshine*.ppkg ./artifacts/sunshine.pkg + + # testing only + # ls ~/ports/multimedia/sunshine + # cat ~/ports/multimedia/sunshine/Portfile + # cat /opt/local/etc/macports/sources.conf + # cat ~/ports/Portindex + # port search sunshine + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: sunshine-macports + path: artifacts/ + + - name: Create Release + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + uses: SunshineStream/actions/create_release@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + next_version: ${{ needs.check_changelog.outputs.next_version }} + last_version: ${{ needs.check_changelog.outputs.last_version }} + release_body: ${{ needs.check_changelog.outputs.release_body }} build_win: name: Windows