release #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow builds Python distribution packages using cibuildwheel tool and | |
# environment and publishes packages as a part of a GitHub release. Also it | |
# releases container image to the DockerHub. | |
# This workflow uses actions that are not certified by GitHub. They are | |
# provided by a third-party and are governed by separate terms of service, | |
# privacy policy, and support documentation. | |
name: release | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
jobs: | |
build-wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-20.04", "macos-13", "macos-14"] | |
max-parallel: 3 | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- run: | | |
echo "REF_NAME=${{github.ref_name}}" | tee -a $GITHUB_ENV | |
echo "EVENT_NAME=${{github.event_name}}" | tee -a $GITHUB_ENV | |
echo "PRERELEASE=${{github.event.release.prerelease}}" | tee -a $GITHUB_ENV | |
echo "TAG_NAME=${{github.event.release.tag_name}}" | tee -a $GITHUB_ENV | |
echo "COMMIT_HEAD=${{github.ref_name != '' && github.ref_name || env.GITHUB_SHA}}" | tee -a $GITHUB_ENV | |
- name: Build wheels on ${{ matrix.os }} | |
if: ${{ !startsWith(matrix.os, 'macos') }} | |
uses: pypa/[email protected] | |
env: | |
CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" | |
with: | |
package-dir: ./python | |
- name: Build wheels on ${{ matrix.os }} | |
if: ${{ startsWith(matrix.os, 'macos') }} | |
uses: pypa/[email protected] | |
env: | |
CIBW_BEFORE_ALL: sh -c "./python/install-hyperonc.sh -u https://github.com/${{github.repository}}.git -r ${{env.COMMIT_HEAD}}" | |
with: | |
package-dir: ./python | |
- name: Publish Artifacts on GitHub Release | |
if: github.event.action == 'published' | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./wheelhouse/*.whl | |
tag: ${{ github.ref }} | |
prerelease: ${{ github.event.release.prerelease }} | |
overwrite: true | |
file_glob: true | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-wheels-${{ matrix.os }} | |
path: ./wheelhouse/*.whl | |
publish-test-pypi: | |
name: Publish to Test PyPI | |
permissions: | |
id-token: write | |
environment: | |
name: pypi-test | |
runs-on: ubuntu-latest | |
needs: [build-wheels] | |
if: github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: python-wheels-* | |
merge-multiple: true | |
path: dist | |
- name: Publish package distributions to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
publish-pypi: | |
name: Publish to PyPI | |
permissions: | |
id-token: write | |
environment: | |
name: pypi-production | |
runs-on: ubuntu-latest | |
needs: [build-wheels] | |
if: github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: python-wheels-* | |
merge-multiple: true | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-docker: | |
name: Publish Docker image | |
environment: | |
name: dockerhub-production | |
runs-on: ubuntu-latest | |
needs: [build-wheels] | |
if: github.event.action == 'published' | |
steps: | |
- name: Set up Docker BuildX | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v6 | |
with: | |
load: true | |
build-args: | | |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 | |
tags: trueagi/hyperon:test | |
- name: Test | |
run: | | |
echo "(* 7 6)" | docker run --rm trueagi/hyperon:test metta-repl | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
build-args: | | |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 | |
tags: | | |
trueagi/hyperon:${{github.event.release.tag_name}} | |
trueagi/hyperon:latest |