Skip to content

Publish Packages

Publish Packages #157

Workflow file for this run

name: Publish Packages
on:
workflow_dispatch:
inputs:
origen_metal_python_package:
description: Publish the Origen Metal python package
default: "false"
type: choice
options:
- true
- false
origen_python_package:
description: Publish the Origen python package
default: "false"
type: choice
options:
- true
- false
# build_for_debug_target:
# description: If 'true', does not use the '--release' switch when building Rust libraries
# required: false
# default: "false"
publish_pypi:
description: Publish built packages to PyPi
required: true
default: "false"
type: choice
options:
- true
- false
publish_pypi_test:
description: Publish To PyPI Test Server
required: true
default: "false"
type: choice
options:
- true
- false
publish_github_release:
description: Publish built packages to Github Release page
required: true
default: "false"
type: choice
options:
- true
- false
prerelease:
description: Indicate that any release is a pre/dev release
required: true
default: "true"
type: choice
options:
- true
- false
# id:
# description: Set the run ID to a known value
# required: false
# type: number
env:
om_ver_file: om_version
origen_ver_file: origen_version
jobs:
precheck:
# Need to make sure that only one publish action is running at a time to avoid releases stepping on each other.
# GA's concurrency only allows for this job replacing previous jobs, but we want the opposite, otherwise we might end up
# with imcomplete or duplicate releases.
runs-on: ubuntu-latest
steps:
- name: Query Concurrency
id: query-concurrency
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'always'
do_not_skip: '[]'
- name: Check Concurrency
uses: actions/github-script@v7
if: ${{ steps.query-concurrency.outputs.should_skip == 'true' }}
with:
script: |
core.setFailed('Found existing publish workflow: ${{ steps.query-concurrency.outputs.skipped_by.htmlUrl }}')
build_manylinux:
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS_FOR_RELEASE) }}
needs: [precheck]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Run Build Script in Docker container
uses: addnab/docker-run-action@v3
with:
image: quay.io/pypa/manylinux2014_x86_64
options: |
--user root
--volume ${{ github.workspace }}:/tmp/o2
--env GIT_DIR=/tmp/o2
--env OM_VER_FILE=${{ env.om_ver_file }}
--env ORIGEN_VER_FILE=${{ env.origen_ver_file }}
--env RUST_VERSION=${{ fromJSON(vars.RUST_VERSION) }}
--env PYTHON_VERSION=${{ matrix.python-version }}
run: |
source /tmp/o2/.github/workflows/build_manylinux.sh
- name: Display OM Wheelhouse Directory
working-directory: python/origen_metal
run: |
ls wheelhouse
echo "OM_WHEEL=$( ls wheelhouse | head -1 )" >> $GITHUB_ENV
- name: Display OM Wheel Name
run: |
echo ${{ env.OM_WHEEL }}
- name: Upload Origen Metal Python Package Artifact
uses: actions/upload-artifact@v3
with:
name: om_wheels
path: python/origen_metal/wheelhouse/${{ env.OM_WHEEL }}
- name: Upload OM Python Package Version
uses: actions/upload-artifact@v3
with:
name: ${{ env.om_ver_file }}
path: python/origen_metal/${{ env.om_ver_file }}
- name: Display Origen Wheelhouse Directory
working-directory: python/origen
run: |
ls wheelhouse
echo "ORIGEN_WHEEL=$( ls wheelhouse | head -1 )" >> $GITHUB_ENV
- name: Display Origen Wheelhouse Directory
run: |
ls -al python/origen/origen/__bin__/bin
ls -al rust/pyapi/target/release
echo ${{ env.ORIGEN_WHEEL }}
- name: Upload Origen Python Package Artifact
uses: actions/upload-artifact@v3
with:
name: origen_wheels
path: python/origen/wheelhouse/${{ env.ORIGEN_WHEEL }}
- name: Upload Origen Python Package Version
uses: actions/upload-artifact@v3
with:
name: ${{ env.origen_ver_file }}
path: python/origen/${{ env.origen_ver_file }}
- name: Upload CLI as a standalone entity
uses: actions/upload-artifact@v3
with:
name: cli
path: python/origen/origen/__bin__/bin/origen
build_windows:
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS) }}
needs: [precheck]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ fromJSON(vars.RUST_VERSION) }}
rustflags:
- name: Override Project Rust Version
run: rustup override set ${{ fromJSON(vars.RUST_VERSION) }}
- name: Check Rust Version
run: |
rustc --version
cargo --version
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python Version
run: python -c "import sys; print(sys.version)"
- name: Install Poetry
run: |
pip install poetry==1.3.2
poetry --version
- name: Build Origen Metal Python Package
working-directory: python/origen_metal
run: poetry build --format wheel
- name: Display Dist Directory
working-directory: python/origen_metal/dist
run: ls
- name: Upload Origen Metal Python Package Artifact
uses: actions/upload-artifact@v3
with:
name: om_wheels
path: python/origen_metal/dist/origen_metal*
- name: Get OM Python Package Version
working-directory: python/origen_metal
run: poetry version -s > ${{ env.om_ver_file }}
- name: Upload OM Python Package Version
uses: actions/upload-artifact@v3
with:
name: ${{ env.om_ver_file }}
path: python/origen_metal/${{ env.om_ver_file }}
# - name: Build Origen CLI
# working-directory: rust/origen/cli
# run: cargo build --bins --release
# - name: Add Origen to PATH (Linux)
# if: matrix.os == 'ubuntu-latest'
# run: echo "${{ github.workspace }}/rust/origen/target/release" >> $GITHUB_PATH
# - name: Add Origen to PATH (Windows)
# if: matrix.os == 'windows-latest'
# run: echo "${{ github.workspace }}/rust/origen/target/release" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# - name: Display Origen CLI Version
# run: origen -v
# - name: Build PyAPI
# working-directory: rust/pyapi
# run: cargo build --release
# - name: Setup App Env
# working-directory: python
# run: origen env setup
# - name: Display Origen App Version
# working-directory: python
# run: origen -v
- name: Build Origen Python Package
working-directory: python/origen
run: poetry build --format wheel
- name: Display Dist Directory
working-directory: python/origen/dist
run: ls
- name: Upload Origen Python Package Artifact
uses: actions/upload-artifact@v3
with:
name: origen_wheels
path: python/origen/dist/origen*
- name: Get Origen Python Package Version
working-directory: python/origen
run: poetry version -s > ${{ env.origen_ver_file }}
- name: Upload Origen Python Package Version
uses: actions/upload-artifact@v3
with:
name: ${{ env.origen_ver_file }}
path: python/origen/${{ env.origen_ver_file }}
# - name: "Publish To PyPi"
# if: ${{ github.event.inputs.publish_pypi }} == true
# working_directory: python
# run: |
# echo "Publishing to PyPi"
# # poetry publish ...
# - name: "Publish To PyPi Test Server"
# if: ${{ github.event.inputs.publish_pypi_test == 'true' }}
# working-directory: python
# run: |
# echo "Publishing to PyPi Test Server"
# poetry config repositories.pypi-test https://test.pypi.org/legacy/
# poetry config pypi-token.pypi-test ${{ secrets.PYPI_TEST_SERVER_API_TOKEN }}
# poetry publish -r pypi-test
# - name: pypi-publish
# if: ${{ github.event.inputs.publish_pypi_test == 'true' }}
# uses: pypa/[email protected]
# with:
# packages_dir: python/dist/
# user: __token__
# password: ${{ secrets.PYPI_TEST_SERVER_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# skip_existing: true
# - name: "Publish To Github Releases"
# if: ${{ github.event.inputs.publish_github_release }} == true
# working_directory: python
# run: |
# echo "Publishing to Github Releases"
# # ...
show_wheels:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
steps:
- name: Retrieve OM Wheels
uses: actions/download-artifact@v3
with:
name: om_wheels
path: om_wheels
- name: List OM Wheels
run: ls -al ./om_wheels
- name: Retrieve Origen Wheels
uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen_wheels
- name: List Origen Wheels
run: ls -al ./origen_wheels
- name: Upload CLI as a standalone entity
uses: actions/upload-artifact@v3
with:
name: cli
path: python\origen\origen\__bin__\bin\origen.exe
publish_to_pypi_test:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
if: ${{ github.event.inputs.publish_pypi_test == 'true' }}
steps:
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: om_wheels
path: om_wheels
- name: List OM Wheels
run: ls -al ./om_wheels
- name: Push To PyPi Test Server
if: ${{ github.event.inputs.origen_metal_python_package == 'true' }}
uses: pypa/[email protected]
with:
packages-dir: om_wheels
password: ${{ secrets.PYPI_TEST_SERVER_API_TOKEN_OM }}
repository-url: https://test.pypi.org/legacy/
verify-metadata: false
verbose: true
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen_wheels
- name: List Origen Wheels
run: ls -al ./origen_wheels
- name: Push To PyPi Test Server
if: ${{ github.event.inputs.origen_python_package == 'true' }}
uses: pypa/[email protected]
with:
packages-dir: origen_wheels
password: ${{ secrets.PYPI_TEST_SERVER_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verify-metadata: false
verbose: true
publish_to_pypi:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
if: ${{ github.event.inputs.publish_pypi == 'true' }}
steps:
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: om_wheels
path: om_wheels
- name: List OM Wheels
run: ls -al ./om_wheels
- name: Push To PyPi Server
if: ${{ github.event.inputs.origen_metal_python_package == 'true' }}
uses: pypa/[email protected]
with:
packages-dir: om_wheels
password: ${{ secrets.PYPI_OM_API_TOKEN }}
verify-metadata: false
verbose: true
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen_wheels
- name: List Origen Wheels
run: ls -al ./origen_wheels
- name: Push To PyPi Server
if: ${{ github.event.inputs.origen_python_package == 'true' }}
uses: pypa/[email protected]
with:
packages-dir: origen_wheels
password: ${{ secrets.PYPI_ORIGEN_API_TOKEN }}
verify-metadata: false
verbose: true
publish_github_release:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
if: ${{ github.event.inputs.publish_github_release == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: om_wheels
path: origen_metal
- uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen
- name: Check wheels directories
run: |
ls -al ./origen_metal
ls -al ./origen
- uses: actions/download-artifact@v3
with:
name: cli
path: cli
- name: Show downloaded artifact directories
run: |
ls -al ./origen_metal
ls -al ./origen
ls -al ./cli
- uses: actions/download-artifact@v3
with:
name: ${{ env.om_ver_file }}
- uses: actions/download-artifact@v3
with:
name: ${{ env.origen_ver_file }}
- uses: vimtor/[email protected]
with:
files: origen_metal
dest: origen_metal.zip
- uses: vimtor/[email protected]
with:
files: origen
dest: origen.zip
- uses: vimtor/[email protected]
with:
files: cli
dest: cli.zip
- name: Get OM/Origen Versions
run: |
ls -al
cat ./${{ env.om_ver_file }}
cat ./${{ env.origen_ver_file }}
echo "om_version=$(cat ./${{ env.om_ver_file }})" >> $GITHUB_ENV
echo "origen_version=$(cat ./${{ env.origen_ver_file }})" >> $GITHUB_ENV
- name: Show Versions
run: |
echo ${{ env.om_version }}
echo ${{ env.origen_version }}
- name: Figure Out Tag
run: |
echo "tag=commit-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Display Tag
run: echo ${{ env.tag }}
- name: Generate Github Release
uses: ncipollo/release-action@v1
with:
artifacts: ./origen_metal.zip, ./origen.zip, cli.zip
artifactErrorsFailBuild: true
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
commit: ${{ github.sha }}
tag: ${{ env.tag }}
cleanup:
needs: [precheck, build_manylinux, build_windows, publish_to_pypi_test, publish_to_pypi, publish_github_release, show_wheels]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- run: |
echo "Begin Clean Up..."
echo "No Clean Up Tasks!"