From ad37cc01d2d13a019b053b448aa0f7dfa631365e Mon Sep 17 00:00:00 2001 From: Nour Yosri Date: Tue, 9 Jan 2024 17:38:46 -0800 Subject: [PATCH 1/4] use token to upload to pypi --- .github/workflows/release-main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index 6fe2b6e6a2e..f923eb995c5 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -22,12 +22,9 @@ jobs: python -m pip install --upgrade pip pip install setuptools wheel twine - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USER }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASS }} run: | export CIRQ_PRE_RELEASE_VERSION=$(dev_tools/packaging/generate-dev-version-id.sh) [[ "$CIRQ_PRE_RELEASE_VERSION" =~ .*dev.* ]] && echo "Deploying dev version '$CIRQ_PRE_RELEASE_VERSION'" || (echo "not dev version"; exit 1) out_dir="${PWD}/dist" dev_tools/packaging/produce-package.sh ${out_dir} $CIRQ_PRE_RELEASE_VERSION - twine upload "${out_dir}/*" + twine upload "${out_dir}/*" -u __token__ -p ${{ secrets.CIRQ_PYPI_TOKEN }} From d84fb2c8b50c835730d43ec9dd073e49d6743d30 Mon Sep 17 00:00:00 2001 From: Nour Yosri Date: Tue, 9 Jan 2024 18:07:11 -0800 Subject: [PATCH 2/4] add a pypi config file --- .github/workflows/release-main.yml | 5 ++++- dev_tools/packaging/create_pypirc.sh | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 dev_tools/packaging/create_pypirc.sh diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index f923eb995c5..877aca4a905 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -21,10 +21,13 @@ jobs: run: | python -m pip install --upgrade pip pip install setuptools wheel twine + - name: Create PYPI config file + run: | + dev_tools/packaging/create_pypirc.sh - name: Build and publish run: | export CIRQ_PRE_RELEASE_VERSION=$(dev_tools/packaging/generate-dev-version-id.sh) [[ "$CIRQ_PRE_RELEASE_VERSION" =~ .*dev.* ]] && echo "Deploying dev version '$CIRQ_PRE_RELEASE_VERSION'" || (echo "not dev version"; exit 1) out_dir="${PWD}/dist" dev_tools/packaging/produce-package.sh ${out_dir} $CIRQ_PRE_RELEASE_VERSION - twine upload "${out_dir}/*" -u __token__ -p ${{ secrets.CIRQ_PYPI_TOKEN }} + twine upload "${out_dir}/*" diff --git a/dev_tools/packaging/create_pypirc.sh b/dev_tools/packaging/create_pypirc.sh new file mode 100644 index 00000000000..e4f3bc11baf --- /dev/null +++ b/dev_tools/packaging/create_pypirc.sh @@ -0,0 +1,9 @@ +echo """ +[pypi] +username = __token__ +password = ${{ secrets.CIRQ_PYPI_TOKEN }} + +[testpypi] +username = __token__ +password = ${{ secrets.CIRQ_TEST_PYPI_TOKEN }} +""" >> $HOME/.pypirc \ No newline at end of file From 75adbfa38a8813e1197ffc57e3df0685899c5c77 Mon Sep 17 00:00:00 2001 From: Nour Yosri Date: Wed, 10 Jan 2024 08:14:14 -0800 Subject: [PATCH 3/4] add comment and fix string substitution --- .github/workflows/release-main.yml | 3 +++ dev_tools/packaging/create_pypirc.sh | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index 877aca4a905..15e8bb67774 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -22,6 +22,9 @@ jobs: python -m pip install --upgrade pip pip install setuptools wheel twine - name: Create PYPI config file + env: + CIRQ_PYPI_TOKEN: ${{ secrets.CIRQ_PYPI_TOKEN }} + CIRQ_TEST_PYPI_TOKEN: ${{ secrets.CIRQ_TEST_PYPI_TOKEN }} run: | dev_tools/packaging/create_pypirc.sh - name: Build and publish diff --git a/dev_tools/packaging/create_pypirc.sh b/dev_tools/packaging/create_pypirc.sh index e4f3bc11baf..dd8c9354694 100644 --- a/dev_tools/packaging/create_pypirc.sh +++ b/dev_tools/packaging/create_pypirc.sh @@ -1,9 +1,12 @@ +#!bin/bash + +# Create default pypi config file with token authentication. echo """ [pypi] username = __token__ -password = ${{ secrets.CIRQ_PYPI_TOKEN }} +password = ${CIRQ_PYPI_TOKEN} [testpypi] username = __token__ -password = ${{ secrets.CIRQ_TEST_PYPI_TOKEN }} -""" >> $HOME/.pypirc \ No newline at end of file +password = ${CIRQ_TEST_PYPI_TOKEN} +""" >> $HOME/.pypirc From 18e6b10bbea5d18d447a5d5fb10ef5d45dfeac2c Mon Sep 17 00:00:00 2001 From: Nour Yosri Date: Wed, 10 Jan 2024 08:17:01 -0800 Subject: [PATCH 4/4] nit --- dev_tools/packaging/create_pypirc.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev_tools/packaging/create_pypirc.sh b/dev_tools/packaging/create_pypirc.sh index dd8c9354694..8adaf3b8a2f 100644 --- a/dev_tools/packaging/create_pypirc.sh +++ b/dev_tools/packaging/create_pypirc.sh @@ -1,6 +1,7 @@ #!bin/bash # Create default pypi config file with token authentication. +# refrence: https://packaging.python.org/en/latest/specifications/pypirc/#common-configurations echo """ [pypi] username = __token__