From e4126d3928ded390a1136ee383d01735ce62abc4 Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Fri, 13 Dec 2024 08:36:09 +0100 Subject: [PATCH 1/6] workflows/docs: split build and deploy, update dependencies, restrict tag --- .github/workflows/docs.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 849c6cf..54329d3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,28 +1,19 @@ name: Deploy documentation on: - # Runs on version tags pushes push: tags: - - 'v*' + - 'v[0-9]+.[0-9]+.[0-9]+' # Runs on manual triggers workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" cancel-in-progress: false jobs: - deploy: + build: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -30,14 +21,16 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + persist-credentials: false - name: Install Poetry uses: abatilo/actions-poetry@v2 with: - poetry-version: '1.7.1' + poetry-version: '1.8.3' - name: Install Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' cache: "poetry" - name: Check Poetry lock file consistency run: poetry check --lock @@ -53,6 +46,17 @@ jobs: uses: actions/upload-pages-artifact@v3 with: path: 'docs/_build' + + deploy: + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 From b38b714213f7aa6f278efb42e3f3c22f01b035e3 Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Fri, 13 Dec 2024 08:37:21 +0100 Subject: [PATCH 2/6] workflows/release: quote expansions, upgrade dependencies, retrict tag --- .github/workflows/release.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db4370a..1a1f6e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release Artifacts on: push: tags: - - 'v*' + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: wheel-build: name: Build and Publish Release Artifacts @@ -14,14 +14,16 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + persist-credentials: false - name: Install Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' - name: Install Poetry uses: abatilo/actions-poetry@v2 with: - poetry-version: '1.7.1' + poetry-version: '1.8.3' - name: Install release dependencies run: pip install -U typer mistletoe - name: Build packages @@ -33,11 +35,12 @@ jobs: with: path: ./dist/qiskit* - name: Extract changelog - run: python scripts/extract-changelog.py ${{ github.ref_name }} | tee ${{ github.workspace }}-CHANGELOG.txt + run: | + python scripts/extract-changelog.py "${{ github.ref_name }}" | tee "${{ github.workspace }}-CHANGELOG.txt" - name: Create Github release uses: softprops/action-gh-release@v1 with: files: ./dist/qiskit* - body_path: ${{ github.workspace }}-CHANGELOG.txt + body_path: "${{ github.workspace }}-CHANGELOG.txt" - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 From 56e67dc8132c1d59df57304ffb5477a2e03e1e9b Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Fri, 13 Dec 2024 08:38:23 +0100 Subject: [PATCH 3/6] workflows/poetry: upgrade poetry, remove credentials persistence --- .github/workflows/poetry.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/poetry.yml b/.github/workflows/poetry.yml index f54d16b..dbf61be 100644 --- a/.github/workflows/poetry.yml +++ b/.github/workflows/poetry.yml @@ -15,10 +15,12 @@ jobs: strategy: matrix: python-version: ['3.9', '3.10', '3.11', '3.12'] - poetry-version: [1.7.1] + poetry-version: [1.8.3] os: ["ubuntu-latest", "windows-latest"] steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Install poetry uses: abatilo/actions-poetry@v2 with: From f396a30459da80f30451468f817e9c5c618d0928 Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Fri, 13 Dec 2024 09:08:04 +0100 Subject: [PATCH 4/6] workflows/release: split build, release creation, and deployment into separate jobs --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a1f6e9..05fa323 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,13 +4,10 @@ on: tags: - 'v[0-9]+.[0-9]+.[0-9]+' jobs: - wheel-build: - name: Build and Publish Release Artifacts - runs-on: ubuntu-latest + build: + name: Build release artifacts environment: release - permissions: - id-token: write - contents: write + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -30,17 +27,37 @@ jobs: run: | poetry build shell: bash + - name: Extract changelog + run: | + python scripts/extract-changelog.py "${{ github.ref_name }}" | tee RELEASE_CHANGELOG.txt - name: Upload artifacts uses: actions/upload-artifact@v4 with: - path: ./dist/qiskit* - - name: Extract changelog - run: | - python scripts/extract-changelog.py "${{ github.ref_name }}" | tee "${{ github.workspace }}-CHANGELOG.txt" + path: | + ./dist/qiskit* + RELEASE_CHANGELOG.txt + + create_release: + name: Create GitHub release + needs: build + environment: release + permissions: + contents: write + runs-on: ubuntu-latest + steps: - name: Create Github release uses: softprops/action-gh-release@v1 with: files: ./dist/qiskit* - body_path: "${{ github.workspace }}-CHANGELOG.txt" + body_path: "RELEASE_CHANGELOG.txt" + + deploy: + name: Deploy to PyPI + needs: build + environment: release + permissions: + id-token: write + runs-on: ubuntu-latest + steps: - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 From 64d6a1390852bfe9a414d4d21997802bfa999b24 Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Fri, 13 Dec 2024 09:24:27 +0100 Subject: [PATCH 5/6] workflows/poetry: install all extras before linting --- .github/workflows/poetry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/poetry.yml b/.github/workflows/poetry.yml index dbf61be..e36e5e6 100644 --- a/.github/workflows/poetry.yml +++ b/.github/workflows/poetry.yml @@ -67,7 +67,7 @@ jobs: poetry run python examples/number_partition.py if: startsWith(matrix.os, 'windows') - name: Install all dependencies - run: poetry install --sync --extras test + run: poetry install --sync --all-extras - name: Check version numbers consistency run: poetry run poe version_check if: startsWith(matrix.os, 'ubuntu') From 0b0008881abd39654acf8997260d4b1e08c62043 Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Fri, 13 Dec 2024 09:31:16 +0100 Subject: [PATCH 6/6] workflows/release: remove template expansion in shell script --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05fa323..af0cc70 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,10 @@ jobs: shell: bash - name: Extract changelog run: | - python scripts/extract-changelog.py "${{ github.ref_name }}" | tee RELEASE_CHANGELOG.txt + python scripts/extract-changelog.py "${TAG_NAME}" | tee RELEASE_CHANGELOG.txt + shell: bash + env: + TAG_NAME: ${{ github.ref_name }} - name: Upload artifacts uses: actions/upload-artifact@v4 with: