7
7
# Only match non-prerelease tags.
8
8
- ' [0-9]+.[0-9]+.[0-9]'
9
9
workflow_dispatch :
10
- inputs :
11
- deploy_prefix :
12
- description : " Deployment prefix (leave blank for the root): https://qiskit.org/documentation/<prefix>."
13
- required : false
14
- type : string
15
- do_deployment :
16
- description : " Push to qiskit.org?"
17
- required : false
18
- type : boolean
19
10
20
11
jobs :
21
12
build :
22
13
if : github.repository_owner == 'Qiskit'
23
14
name : Build
24
15
runs-on : ubuntu-latest
25
16
26
- outputs :
27
- latest_tag : ${{ steps.latest_tag.outputs.latest_tag }}
28
-
29
17
steps :
30
18
- uses : actions/checkout@v4
31
19
with :
32
20
# We need to fetch the whole history so 'reno' can do its job and we can inspect tags.
33
21
fetch-depth : 0
34
22
35
- - name : Determine latest full release tag
36
- id : latest_tag
37
- run : |
38
- set -e
39
- latest_tag=$(git tag --list --sort=-version:refname | sed -n '/^[0-9]\+\.[0-9]\+\.[0-9]\+$/p' | head -n 1)
40
- echo "Latest release tag: '$latest_tag'"
41
- echo "latest_tag=$latest_tag" >> "$GITHUB_OUTPUT"
42
-
43
- - uses : actions/setup-python@v4
23
+ - uses : actions/setup-python@v5
44
24
name : Install Python
45
25
with :
46
26
# Sync with 'documentationPythonVersion' in 'azure-pipelines.yml'.
@@ -49,116 +29,27 @@ jobs:
49
29
- name : Install dependencies
50
30
run : tools/install_ubuntu_docs_dependencies.sh
51
31
32
+ - name : Determine GitHub branch name
33
+ run : |
34
+ # Tags like 1.0.0 and 1.0.0rc1 should point to their stable branch. We do this
35
+ # to reduce the diff in the qiskit/documentation repository between generating
36
+ # the API docs from a tag release versus a workflow_dispatch.
37
+ if [[ $GITHUB_REF_NAME =~ ^([0-9]+\.[0-9]+) ]]; then
38
+ BRANCH_NAME="stable/${BASH_REMATCH[1]}"
39
+ else
40
+ BRANCH_NAME="$GITHUB_REF_NAME"
41
+ fi
42
+ echo "Using branch '${BRANCH_NAME}' for GitHub source code links"
43
+ echo "QISKIT_DOCS_GITHUB_BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
44
+
52
45
- name : Build documentation
53
46
run : tox run -e docs
54
-
55
47
- name : Store built documentation artifact
56
- uses : actions/upload-artifact@v3
48
+ uses : actions/upload-artifact@v4
57
49
with :
58
50
name : qiskit-docs
59
51
path : |
60
52
./docs/_build/html/*
61
53
!**/.doctrees
62
54
!**/.buildinfo
63
55
if-no-files-found : error
64
-
65
- deploy :
66
- if : github.event_name != 'workflow_dispatch' || inputs.do_deployment
67
- name : Deploy to qiskit.org
68
- needs : [build]
69
- runs-on : ubuntu-latest
70
-
71
- steps :
72
- - uses : actions/checkout@v4
73
- with :
74
- path : qiskit
75
-
76
- - uses : actions/download-artifact@v3
77
- with :
78
- name : qiskit-docs
79
- path : deploy
80
-
81
- - id : choose
82
- name : Choose deployment location(s)
83
- run : |
84
- set -e
85
- declare -a prefixes
86
- case ${{ github.event_name }} in
87
- push)
88
- case ${{ github.ref_type }} in
89
- branch)
90
- if [[ "$GITHUB_REF_NAME" != "main" ]]; then
91
- echo "Push to unhandled branch '$GITHUB_REF_NAME'" >&2
92
- exit 1
93
- fi
94
-
95
- prefixes+=( "dev" )
96
- ;;
97
- tag)
98
- tag=$GITHUB_REF_NAME
99
- echo "Full tag: ${tag}"
100
- IFS=. read -ra version <<< "$tag"
101
- minor_version="${version[0]}.${version[1]}"
102
- echo "Minor version: ${minor_version}"
103
- prefixes+=( "stable/${minor_version}" )
104
- if [[ "$tag" == "$LATEST_TAG" ]]; then
105
- # Deploy to the root as well.
106
- prefixes+=( "" )
107
- fi
108
- ;;
109
- *)
110
- echo "Unhandled reference type '${{ github.ref_type }}'" >&2
111
- exit 1
112
- ;;
113
- esac
114
- ;;
115
- workflow_dispatch)
116
- prefixes+=( "$WORKFLOW_DISPATCH_PREFIX" )
117
- ;;
118
- *)
119
- echo "Unhandled GitHub event ${{ github.event_name }}" >&2
120
- exit 1
121
- ;;
122
- esac
123
- # Join the array of prefixes into a colon-delimited list for
124
- # serialisation. This includes a trailing colon, so we can detect
125
- # the presence of the empty string, even if it's the only prefix.
126
- if [[ "${#prefixes[@]}" -gt 0 ]]; then
127
- joined_prefixes=$(printf "%s:" "${prefixes[@]}")
128
- echo "Chosen deployment prefixes: '$joined_prefixes'"
129
- echo "joined_prefixes=$joined_prefixes" >> "$GITHUB_OUTPUT"
130
- else
131
- echo "Nothing to deploy to."
132
- fi
133
- env :
134
- LATEST_TAG : ${{ needs.build.outputs.latest_tag }}
135
- GITHUB_REF_NAME : ${{ github.ref_name }}
136
- WORKFLOW_DISPATCH_PREFIX : ${{ inputs.deploy_prefix }}
137
-
138
- - name : Install rclone
139
- run : |
140
- set -e
141
- curl https://downloads.rclone.org/rclone-current-linux-amd64.deb -o rclone.deb
142
- sudo apt-get install -y ./rclone.deb
143
-
144
- - name : Deploy to qiskit.org
145
- if : ${{ steps.choose.outputs.joined_prefixes != '' }}
146
- run : |
147
- set -e
148
- RCLONE_CONFIG=$(rclone config file | tail -1)
149
- openssl aes-256-cbc -K "$RCLONE_KEY" -iv "$RCLONE_IV" -in qiskit/tools/rclone.conf.enc -out "$RCLONE_CONFIG" -d
150
- IFS=: read -ra prefixes <<< "$JOINED_PREFIXES"
151
- for prefix in "${prefixes[@]}"; do
152
- # The 'documentation' bit of the prefix is hard-coded in this step
153
- # rather than being chosen during the prefix-choosing portion
154
- # because we don't want to allow the 'workflow_dispatch' event
155
- # trigger to accidentally allow a deployment to a dodgy prefix that
156
- # wipes out _everything_ on qiskit.org.
157
- location=documentation/$prefix
158
- echo "Deploying to 'qiskit.org/$location'"
159
- rclone sync --progress --exclude-from qiskit/tools/docs_exclude.txt deploy "IBMCOS:qiskit-org-web-resources/$location"
160
- done
161
- env :
162
- JOINED_PREFIXES : ${{ steps.choose.outputs.joined_prefixes }}
163
- RCLONE_KEY : ${{ secrets.ENCRYPTED_RCLONE_KEY}}
164
- RCLONE_IV : ${{ secrets.ENCRYPTED_RCLONE_IV }}
0 commit comments