Skip to content

Build macOS pkg Installer #261

Build macOS pkg Installer

Build macOS pkg Installer #261

Workflow file for this run

name: Build macOS pkg Installer
on:
workflow_dispatch:
inputs:
incoming_ref:
description: >
The ref from Cantera/cantera to be built. Can be a tag, commit hash,
or branch name.
required: true
default: "main"
concurrency:
group: ${{ github.ref }}-${{ github.event.inputs.incoming_ref }}
cancel-in-progress: true
env:
MW_HEADERS_DIR: ${{ github.workspace }}/mw_headers
MACOSX_DEPLOYMENT_TARGET: "10.15"
PKG_DIR: ${{ github.workspace }}
ACTION_URL: "https://github.com/Cantera/cantera-macos-pkg/actions/runs/${{ github.run_id }}"
INCOMING_REF: ${{ github.event.inputs.incoming_ref }}
jobs:
post-pending-status:
name: Post a pending workflow status to Cantera/cantera
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }}
outputs:
incoming-sha: ${{ steps.get-incoming-sha.outputs.incoming-sha }}
tag-ref: ${{ steps.munge-incoming-ref.outputs.tag-ref }}
steps:
- name: Munge the incoming ref
id: munge-incoming-ref
run: |
import os
import re
from pathlib import Path
INCOMING_REF = "${{ github.event.inputs.incoming_ref }}"
if INCOMING_REF.startswith("refs/"):
INCOMING_REF = INCOMING_REF.replace("refs/", "")
elif re.match(r"^v\d\.\d\.\d.*$", INCOMING_REF) is not None:
INCOMING_REF = f"tags/{INCOMING_REF}"
else:
INCOMING_REF = f"heads/{INCOMING_REF}"
TAG_REF = "false"
if INCOMING_REF.startswith("tags"):
TAG_REF = "true"
Path(os.environ["GITHUB_ENV"]).write_text(
f"INCOMING_REF={INCOMING_REF}\n"
f"TAG_REF={TAG_REF}"
)
Path(os.environ["GITHUB_OUTPUT"]).write_text(
f"tag-ref={TAG_REF}"
)
shell: python
- name: Get the SHA associated with the incoming ref
id: get-incoming-sha
run: |
INCOMING_SHA=$(gh api repos/cantera/cantera/git/matching-refs/${INCOMING_REF} \
-H "Accept: application/vnd.github.v3+json" --jq ".[0].object.sha")
echo "INCOMING_SHA=${INCOMING_SHA}" >> $GITHUB_ENV
echo "incoming-sha=${INCOMING_SHA}" >> $GITHUB_OUTPUT
- name: Post the status to the upstream commit
id: set-the-status
if: env.TAG_REF == 'false'
run: |
gh api repos/cantera/cantera/statuses/${INCOMING_SHA} \
-H "Accept: application/vnd.github.v3+json" \
--field state='pending' \
--field target_url=$ACTION_URL \
--field context='macOS Package Build' \
--field description="Pending build" \
--silent
build-intel:
name: Build Intel-based package
runs-on: macos-11
needs:
- "post-pending-status"
outputs:
job-status: ${{ job.status }}
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Checkout Cantera repository
uses: actions/checkout@v3
with:
submodules: recursive
repository: Cantera/cantera
path: cantera
ref: ${{ github.event.inputs.incoming_ref }}
# The known_hosts key is generated with `ssh-keygen -F cantera.org` from a
# machine that has previously logged in to cantera.org and trusts
# that it logged in to the right machine
- name: Set up SSH key and host for cloning MATLAB
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.CTDEPLOY_SSH_KEY }}
known_hosts: ${{ secrets.CTDEPLOY_KNOWN_HOSTS }}
- name: Get the MATLAB headers
run: "rsync -azvP [email protected]:. ${MW_HEADERS_DIR}"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
python -m pip install -U pip setuptools
python -m pip install scons
- name: Install Brew dependencies
run: brew install boost
- name: Install Packages
run: sudo /usr/sbin/installer -pkg Packages.pkg -target /
- name: Build Cantera
working-directory: cantera
run: |
echo "matlab_path='${MW_HEADERS_DIR}'" >> cantera.conf
echo "f90_interface='n'" >> cantera.conf
echo "system_sundials='n'" >> cantera.conf
echo "debug='n'" >> cantera.conf
echo "python_package='none'" >> cantera.conf
echo "prefix='${PKG_DIR}'" >> cantera.conf
echo "layout='compact'" >> cantera.conf
echo "logging='debug'" >> cantera.conf
python3 `which scons` build -j3 boost_inc_dir="$(brew --prefix)/include"
- name: Test Cantera
working-directory: cantera
run: python3 `which scons` test-general test-thermo test-kinetics test-transport
- name: Install Cantera
working-directory: cantera
run: python3 `which scons` install
- name: Package Cantera
run: /usr/local/bin/packagesbuild ./cantera-matlab-interface.pkgproj
- name: Upload the pkg artifact
uses: actions/upload-artifact@v3
with:
path: build/*.pkg
name: intel
send_status_to_cantera:
name: Send jobs status to Cantera/cantera
runs-on: ubuntu-22.04
needs:
- "post-pending-status"
- "build-intel"
if: always()
steps:
- name: Collect statuses
run: |
from collections import Counter
import os
statuses = {
"intel": "${{ needs.build-intel.outputs.job-status }}",
}
# This is a deliberate comparison to the empty string.
if all(v == "success" for v in statuses.values()):
overall_status = "success"
elif any(v in ("cancelled", "") for v in statuses.values()):
overall_status = "error"
elif any(v == "failure" for v in statuses.values()):
overall_status = "failure"
status_counts = Counter(statuses.values())
description = []
if overall_status in ("error", "failure"):
if status_counts.get("success") is not None:
description.append(f"{status_counts['success']} succeeded")
if status_counts.get("cancelled") is not None:
description.append(f"{status_counts['cancelled']} cancelled")
if status_counts.get("failure") is not None:
description.append(f"{status_counts['failure']} failed")
if status_counts.get("") is not None:
description.append(f"{status_counts['']} skipped")
description = ", ".join(description)
else:
description = "Successfully built macOS packages!"
with open(os.environ["GITHUB_ENV"], "a") as gh_env:
gh_env.write(f"OVERALL_STATUS={overall_status}\nDESCRIPTION={description}")
shell: python
- name: Post the status to the upstream commit
if: needs.post-pending-status.outputs.tag-ref == 'false'
run: |
INCOMING_SHA=${{ needs.post-pending-status.outputs.incoming-sha }}
gh api repos/cantera/cantera/statuses/${INCOMING_SHA} \
-H "Accept: application/vnd.github.v3+json" \
--field state="${OVERALL_STATUS}" \
--field target_url=$ACTION_URL \
--field context='macOS Package Build' \
--field description="${DESCRIPTION}" \
--silent
env:
GITHUB_TOKEN: ${{ secrets.CANTERA_REPO_STATUS }}