4.10.0-rc.0 (2024-04-29) #65
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
name: Publish pyQuil | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
description: "Manually publish release" | |
jobs: | |
build-publish: | |
name: Build and Publish | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v3 | |
- uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-in-project: true | |
- name: "Build" | |
run: | | |
poetry build --no-interaction | |
- id: publish | |
name: "Publish" | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
poetry publish | |
export PYQUIL_TAG_VERSION=$(poetry version --short) | |
export PYQUIL_TAG_LATEST=$([[ "$PYQUIL_TAG_VERSION" =~ ^[0-9]+[.][0-9]+[.][0-9]+$ ]] && echo latest || echo) | |
export PYQUIL_TAG_RC=$([[ "$PYQUIL_TAG_VERSION" =~ ^[0-9]+[.][0-9]+[.][0-9]+-rc[.][0-9]+$ ]] && echo rc || echo) | |
echo "PYQUIL_TAG_VERSION=$PYQUIL_TAG_VERSION" >> "$GITHUB_OUTPUT" | |
echo "PYQUIL_TAG_LATEST=$PYQUIL_TAG_LATEST" >> "$GITHUB_OUTPUT" | |
echo "PYQUIL_TAG_RC=$PYQUIL_TAG_RC" >> "$GITHUB_OUTPUT" | |
outputs: | |
PYQUIL_TAG_VERSION: ${{ steps.publish.outputs.PYQUIL_TAG_VERSION }} | |
PYQUIL_TAG_LATEST: ${{ steps.publish.outputs.PYQUIL_TAG_LATEST }} | |
PYQUIL_TAG_RC: ${{ steps.publish.outputs.PYQUIL_TAG_RC }} | |
build-publish-grpc-web: | |
name: Build and Publish (pyquil-grpc-web) | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v3 | |
- uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-in-project: true | |
- name: Patch package metadata for grpc-web | |
run: | | |
pip install toml | |
python scripts/ci_publish_grpc_web.py | |
- name: Poetry Build | |
run: | | |
poetry build --no-interaction | |
- name: Upload wheels as artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
- name: Mint token | |
id: mint | |
uses: tschm/[email protected] | |
- name: Publish the package with poetry | |
run: | | |
poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}' | |
docker-publish: | |
name: Docker Publish | |
runs-on: ubuntu-latest | |
needs: build-publish | |
env: | |
PYQUIL_TAG_VERSION: ${{ needs.build-publish.outputs.PYQUIL_TAG_VERSION }} | |
PYQUIL_TAG_LATEST: ${{ needs.build-publish.outputs.PYQUIL_TAG_LATEST }} | |
PYQUIL_TAG_RC: ${{ needs.build-publish.outputs.PYQUIL_TAG_RC }} | |
steps: | |
# Determine the tags to publish based on the release tag | |
- name: Docker Metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ vars.DOCKER_IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ env.PYQUIL_TAG_VERSION }} | |
type=raw,value=${{ env.PYQUIL_TAG_LATEST }},enable=${{ env.PYQUIL_TAG_LATEST != '' }} | |
type=raw,value=${{ env.PYQUIL_TAG_RC }},enable=${{ env.PYQUIL_TAG_RC != '' }} | |
# Checkout is needed to use the path context: . | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Build and Test | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
tags: "${{ vars.DOCKER_IMAGE_NAME }}:test" | |
build-args: | | |
pyquil_version=${{ env.PYQUIL_TAG_VERSION }} | |
- name: Test Image | |
run: | | |
docker run --rm "${{ vars.DOCKER_IMAGE_NAME }}:test" python -c "from pyquil import get_qc" | |
# Build and publish the image | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and Push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
pyquil_version=${{ env.PYQUIL_TAG_VERSION }} |