name: publish
on:
push:
tags:
- "v*"
jobs:
build-package:
runs-on: linux-aarch64-a3-2
container:
image: swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:8.2.rc1-a3-ubuntu22.04-py3.11
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Config mirrors
run: |
sed -Ei 's@(ports|archive).ubuntu.com@cache-service.nginx-pypi-cache.svc.cluster.local:8081@g' /etc/apt/sources.list
pip config set global.index-url http://cache-service.nginx-pypi-cache.svc.cluster.local/pypi/simple
pip config set global.trusted-host cache-service.nginx-pypi-cache.svc.cluster.local
apt-get update -y
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Update version
run: |
echo "Using tag version: ${GITHUB_REF#refs/tags/v}"
python${{ matrix.python-version }} ci/update_version.py "${GITHUB_REF#refs/tags/v}" --commit "${GITHUB_SHA}"
- name: Build package for Python ${{ matrix.python-version }}
run: |
echo "Building for Python ${{ matrix.python-version }}..."
pip${{ matrix.python-version }} install --upgrade pip
pip${{ matrix.python-version }} install build
python${{ matrix.python-version }} -m build --wheel
- name: Upload package artifacts
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8
with:
name: python-packages-${{ matrix.python-version }}
path: dist/
retention-days: 7
publish-github-release:
needs: build-package
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Download package artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
pattern: python-packages-*
path: dist/
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b
with:
tag_name: ${{ github.ref_name }}
files: dist/*.whl
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-pypi:
needs: build-package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Download package artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
pattern: python-packages-*
path: dist/
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist/