-
Notifications
You must be signed in to change notification settings - Fork 342
117 lines (113 loc) · 3.98 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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 }}