Skip to content

Branch Build (1.480) - main #480

Branch Build (1.480) - main

Branch Build (1.480) - main #480

Workflow file for this run

name: Build
run-name: "Branch Build (${{ github.run_attempt }}.${{ github.run_number }}) - ${{ github.ref_name }}"
on:
workflow_dispatch:
inputs:
amalgam-build:
description: |
(Optional) Amalgam build or version number. Defaults to pinned release.
Examples:
'6807310618',
'https://github.com/howsoai/amalgam/actions/runs/6807310618',
'57.0.1'
required: false
type: string
debug-mode:
description: Enables GDB and Amalgam Fast Memory Integrity checks for all Linux/x86 Pytest jobs.
type: boolean
required: false
default: false
workflow_call:
inputs:
build-type:
required: false
type: string
optional-release-tag:
required: false
type: string
debug-mode:
type: boolean
required: false
default: false
defaults:
run:
shell: bash
jobs:
metadata:
uses: howsoai/.github/.github/workflows/set-metadata.yml@main
secrets: inherit
with:
build-type: ${{ inputs.build-type }}
optional-release-tag: ${{ inputs.optional-release-tag }}
amalgam-build: ${{ inputs.amalgam-build }}
build:
name: Build (${{ matrix.plat }})
needs: ["metadata"]
runs-on: ubuntu-latest
strategy:
matrix:
plat: [manylinux_2_28_x86_64, manylinux_2_29_x86_64, manylinux_2_29_aarch64, macosx_12_0_x86_64, macosx_12_0_arm64, win_amd64, any]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install cibuildwheel
run: >-
python3 -m
pip install
cibuildwheel==2.15.0
build
- name: Download Amalgam linux-amd64
if: matrix.plat == 'manylinux_2_29_x86_64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
# Release artifacts will have a .tar.gz postfix while branch/PR build artifacts will not
if [[ "$run_type" == "release" ]]; then
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64.tar.gz" "$run_id"
else
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64" "$run_id"
fi
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam linux-amd64-228
# Linux version that supports GLIBC 2.28+, most users should use 2.29+ (above)
# This specifically does NOT run on the "any" platform target.
if: matrix.plat == 'manylinux_2_28_x86_64'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
if [[ "$run_type" == "release" ]]; then
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64-228.tar.gz" "$run_id"
else
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64-228" "$run_id"
fi
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam linux-arm64
if: matrix.plat == 'manylinux_2_29_aarch64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
if [[ "$run_type" == "run" ]]; then
pattern="*linux-arm64"
else
pattern="*linux-arm64.tar.gz"
fi
gh $run_type download -D amalgam/lib/linux/arm64 -R "howsoai/amalgam" -p "$pattern" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/arm64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam linux-arm64_8a
if: matrix.plat == 'manylinux_2_29_aarch64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/linux/arm64_8a -R "howsoai/amalgam" -p "*linux-arm64_8a*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/arm64_8a && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam darwin-amd64
if: matrix.plat == 'macosx_12_0_x86_64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/darwin/amd64 -R "howsoai/amalgam" -p "*darwin-amd64*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/darwin/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam darwin-arm64
if: matrix.plat == 'macosx_12_0_arm64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/darwin/arm64 -R "howsoai/amalgam" -p "*darwin-arm64*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/darwin/arm64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam windows-amd64
if: matrix.plat == 'win_amd64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/windows/amd64 -R "howsoai/amalgam" -p "*windows-amd64*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/windows/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Format lib dir and version.json
run: |
version_file=$(find "$(pwd)/amalgam/lib" -type f -name "version.json" | head -n1)
new_version_file="amalgam/lib/version.json"
if [ -f "${version_file}" ]; then
cp "${version_file}" $new_version_file
jq '{version: {amalgam: .version}}' $new_version_file > ${new_version_file}.tmp && mv ${new_version_file}.tmp ${new_version_file}
else
# Fall back to what is checked into repo:
cp version.json $new_version_file
sed -i 's/dependencies/version/g' $new_version_file
fi
cd amalgam/lib
find . -type d -name lib -exec sh -c 'mv {}/* "$(dirname {})"' \;
- name: Set amalgam version metadata
run: |
cd amalgam/lib
build_title=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".build_title')
build_date=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".build_date')
head_sha=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".head_sha')
url=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".url')
jq --arg head_sha "$head_sha" '.version |= . + {"amalgam_sha": $head_sha}' version.json > temp.json && mv temp.json version.json
jq --arg url "$url" '.version |= . + {"amalgam_url": $url}' version.json > temp.json && mv temp.json version.json
jq --arg build_date "$build_date" '.version |= . + {"amalgam_build_date": $build_date}' version.json > temp.json && mv temp.json version.json
jq --arg build_title "$build_title" '.version |= . + {"amalgam_display_title": $build_title}' version.json > temp.json && mv temp.json version.json
cat version.json
- name: Build wheels
run: |
python3 -m build --wheel --outdir wheelhouse/ .
mkdir -p dist/
mv wheelhouse/*.whl dist/amalgam_lang-${{ needs.metadata.outputs.version }}-py3-none-${{ matrix.plat }}.whl
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.metadata.outputs.version }}
- name: Build tarball
if: matrix.plat == 'any'
run: |
python3 -m build --sdist --outdir dist/ .
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.metadata.outputs.version }}
- name: Upload Tarball Artifact
if: matrix.plat == 'any'
uses: actions/upload-artifact@v4
with:
name: amalgam_lang-${{ needs.metadata.outputs.version }}
path: dist/amalgam_lang-*.tar.gz
if-no-files-found: error
- name: Upload Wheel Artifact
uses: actions/upload-artifact@v4
with:
name: amalgam_lang-${{ needs.metadata.outputs.version }}-py3-none-${{ matrix.plat }}
path: dist/amalgam_lang-*.whl
if-no-files-found: error
workflow-summary:
needs: ['metadata', 'build']
uses: "howsoai/.github/.github/workflows/workflow-summary.yml@main"
secrets: inherit
with:
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
pytest-linux-3-9-st:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'ubuntu-latest'
platform-pretty: 'Linux'
amalgam-plat-arch: 'linux-amd64'
python-version: '3.9'
config-fp: './config/latest-st-traces-howso.yml'
config-pretty: 'ST'
workers: 'auto'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
pytest-linux-3-12-mt:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'ubuntu-latest'
platform-pretty: 'Linux'
amalgam-plat-arch: 'linux-amd64'
python-version: '3.12'
config-fp: './config/latest-mt-traces-howso.yml'
config-pretty: 'MT'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
pytest-windows-3-12-mt:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'windows-latest'
platform-pretty: 'Windows'
amalgam-plat-arch: 'windows-amd64'
python-version: '3.12'
config-fp: './config/latest-mt-traces-howso.yml'
config-pretty: 'MT'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
pytest-macos-3-12-mt:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'macos-latest'
platform-pretty: 'MacOS'
amalgam-plat-arch: 'darwin-arm64'
python-version: '3.12'
config-fp: './config/latest-mt-traces-howso.yml'
config-pretty: 'MT'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
publish:
if: inputs.build-type == 'release'
needs:
- metadata
- workflow-summary
- pytest-linux-3-9-st
- pytest-linux-3-12-mt
- pytest-macos-3-12-mt
- pytest-windows-3-12-mt
runs-on: ubuntu-latest
environment:
name: PyPi
permissions:
id-token: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./tmp
- name: Configure environment
run: |
mkdir -p dist
find ./tmp -type f -name '*.whl' -exec cp -t ./dist {} +
find ./tmp -type f -name '*.tar.gz' -exec cp -t ./dist {} +
ls -l ./dist
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Publish [PyPi]
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: True
# Experimental feature not yet compatible with our workflow
attestations: False
generate-changelog:
if: inputs.build-type == 'release'
secrets: inherit
needs:
- metadata
uses: "howsoai/.github/.github/workflows/release-notes.yml@main"
release:
if: inputs.build-type == 'release'
needs:
- metadata
- generate-changelog
- workflow-summary
- pytest-linux-3-9-st
- pytest-linux-3-12-mt
- pytest-macos-3-12-mt
- pytest-windows-3-12-mt
- publish
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./tmp
- name: Clean up dir
run: |
mkdir -p dist
find ./tmp -type f -name '*.whl' -exec mv -t ./dist {} +
find ./tmp -type f -name '*.tar.gz' -exec mv -t ./dist {} +
ls ./dist
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.metadata.outputs.version }}
commit: ${{ github.sha }}
name: "${{ github.event.repository.name }} ${{ needs.metadata.outputs.version }}"
artifactErrorsFailBuild: true
body: ${{ needs.generate-changelog.outputs.changelog }}
makeLatest: legacy
artifacts: "dist/*"
artifactContentType: application/gzip