From ce4f5fb95314366b2713a45f32653d2c9ad847bc Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Mon, 17 Feb 2025 17:51:40 -0500 Subject: [PATCH 1/2] fix the release process --- .github/workflows/release.yaml | 112 +++++++++++------- .../generate_github_workflows.py | 10 +- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e1878fc25c6..bd54c60b247 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -84,10 +84,21 @@ jobs: subject-path: dist/deploy/wheels/pantsbuild.pants/**/pantsbuild.pants-*.whl - if: needs.release_info.outputs.is-release == 'true' name: Rename the Pants Pex to its final name for upload - run: 'PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + run: 'PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + pants.version;print(pants.version.VERSION)") + + PY_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + sys;print(f''cp{sys.version_info[0]}{sys.version_info[1]}'')") + + PLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import os;print(f''{os.uname().sysname.lower()}_{os.uname().machine.lower()}'')") + + PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME + echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + ' - continue-on-error: true if: needs.release_info.outputs.is-release == 'true' @@ -97,16 +108,11 @@ jobs: subject-path: dist/src.python.pants/*.pex - if: needs.release_info.outputs.is-release == 'true' name: Upload Wheel and Pex - run: "PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\ - import pants.version;print(pants.version.VERSION)\")\nPY_VER=$(PEX_INTERPRETER=1\ - \ dist/src.python.pants/pants-pex.pex -c \"import sys;print(f'cp{sys.version_info[0]}{sys.version_info[1]}')\"\ - )\nPLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"import\ - \ os;print(f'{os.uname().sysname.lower()}_{os.uname().machine.lower()}')\"\ - )\nPEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex\n\ncurl -L --fail \\\n\ - \ -X POST \\\n -H \"Authorization: Bearer ${{ github.token }}\" \\\n\ - \ -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\ - \ }}?name=$PEX_FILENAME \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\ - \n\nWHL=$(find dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ + run: "curl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{\ + \ github.token }}\" \\\n -H \"Content-Type: application/octet-stream\"\ + \ \\\n ${{ needs.release_info.outputs.release-asset-upload-url }}?name=$PEX_FILENAME\ + \ \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\n\nWHL=$(find\ + \ dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ )\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\ \ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n \"${{\ \ needs.release_info.outputs.release-asset-upload-url }}?name=$(basename $WHL)\"\ @@ -192,10 +198,21 @@ jobs: subject-path: dist/deploy/wheels/pantsbuild.pants/**/pantsbuild.pants-*.whl - if: needs.release_info.outputs.is-release == 'true' name: Rename the Pants Pex to its final name for upload - run: 'PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + run: 'PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + pants.version;print(pants.version.VERSION)") + + PY_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + sys;print(f''cp{sys.version_info[0]}{sys.version_info[1]}'')") + + PLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import os;print(f''{os.uname().sysname.lower()}_{os.uname().machine.lower()}'')") + + PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME + echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + ' - continue-on-error: true if: needs.release_info.outputs.is-release == 'true' @@ -205,16 +222,11 @@ jobs: subject-path: dist/src.python.pants/*.pex - if: needs.release_info.outputs.is-release == 'true' name: Upload Wheel and Pex - run: "PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\ - import pants.version;print(pants.version.VERSION)\")\nPY_VER=$(PEX_INTERPRETER=1\ - \ dist/src.python.pants/pants-pex.pex -c \"import sys;print(f'cp{sys.version_info[0]}{sys.version_info[1]}')\"\ - )\nPLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"import\ - \ os;print(f'{os.uname().sysname.lower()}_{os.uname().machine.lower()}')\"\ - )\nPEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex\n\ncurl -L --fail \\\n\ - \ -X POST \\\n -H \"Authorization: Bearer ${{ github.token }}\" \\\n\ - \ -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\ - \ }}?name=$PEX_FILENAME \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\ - \n\nWHL=$(find dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ + run: "curl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{\ + \ github.token }}\" \\\n -H \"Content-Type: application/octet-stream\"\ + \ \\\n ${{ needs.release_info.outputs.release-asset-upload-url }}?name=$PEX_FILENAME\ + \ \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\n\nWHL=$(find\ + \ dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ )\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\ \ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n \"${{\ \ needs.release_info.outputs.release-asset-upload-url }}?name=$(basename $WHL)\"\ @@ -329,10 +341,21 @@ jobs: subject-path: dist/deploy/wheels/pantsbuild.pants/**/pantsbuild.pants-*.whl - if: needs.release_info.outputs.is-release == 'true' name: Rename the Pants Pex to its final name for upload - run: 'PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + run: 'PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + pants.version;print(pants.version.VERSION)") + + PY_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + sys;print(f''cp{sys.version_info[0]}{sys.version_info[1]}'')") + + PLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import os;print(f''{os.uname().sysname.lower()}_{os.uname().machine.lower()}'')") + + PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME + echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + ' - continue-on-error: true if: needs.release_info.outputs.is-release == 'true' @@ -342,16 +365,11 @@ jobs: subject-path: dist/src.python.pants/*.pex - if: needs.release_info.outputs.is-release == 'true' name: Upload Wheel and Pex - run: "PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\ - import pants.version;print(pants.version.VERSION)\")\nPY_VER=$(PEX_INTERPRETER=1\ - \ dist/src.python.pants/pants-pex.pex -c \"import sys;print(f'cp{sys.version_info[0]}{sys.version_info[1]}')\"\ - )\nPLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"import\ - \ os;print(f'{os.uname().sysname.lower()}_{os.uname().machine.lower()}')\"\ - )\nPEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex\n\ncurl -L --fail \\\n\ - \ -X POST \\\n -H \"Authorization: Bearer ${{ github.token }}\" \\\n\ - \ -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\ - \ }}?name=$PEX_FILENAME \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\ - \n\nWHL=$(find dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ + run: "curl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{\ + \ github.token }}\" \\\n -H \"Content-Type: application/octet-stream\"\ + \ \\\n ${{ needs.release_info.outputs.release-asset-upload-url }}?name=$PEX_FILENAME\ + \ \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\n\nWHL=$(find\ + \ dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ )\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\ \ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n \"${{\ \ needs.release_info.outputs.release-asset-upload-url }}?name=$(basename $WHL)\"\ @@ -449,10 +467,21 @@ jobs: subject-path: dist/deploy/wheels/pantsbuild.pants/**/pantsbuild.pants-*.whl - if: needs.release_info.outputs.is-release == 'true' name: Rename the Pants Pex to its final name for upload - run: 'PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + run: 'PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + pants.version;print(pants.version.VERSION)") + + PY_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import + sys;print(f''cp{sys.version_info[0]}{sys.version_info[1]}'')") + + PLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import os;print(f''{os.uname().sysname.lower()}_{os.uname().machine.lower()}'')") + + PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME + echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + ' - continue-on-error: true if: needs.release_info.outputs.is-release == 'true' @@ -462,16 +491,11 @@ jobs: subject-path: dist/src.python.pants/*.pex - if: needs.release_info.outputs.is-release == 'true' name: Upload Wheel and Pex - run: "PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"\ - import pants.version;print(pants.version.VERSION)\")\nPY_VER=$(PEX_INTERPRETER=1\ - \ dist/src.python.pants/pants-pex.pex -c \"import sys;print(f'cp{sys.version_info[0]}{sys.version_info[1]}')\"\ - )\nPLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c \"import\ - \ os;print(f'{os.uname().sysname.lower()}_{os.uname().machine.lower()}')\"\ - )\nPEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex\n\ncurl -L --fail \\\n\ - \ -X POST \\\n -H \"Authorization: Bearer ${{ github.token }}\" \\\n\ - \ -H \"Content-Type: application/octet-stream\" \\\n ${{ needs.release_info.outputs.release-asset-upload-url\ - \ }}?name=$PEX_FILENAME \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\ - \n\nWHL=$(find dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ + run: "curl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{\ + \ github.token }}\" \\\n -H \"Content-Type: application/octet-stream\"\ + \ \\\n ${{ needs.release_info.outputs.release-asset-upload-url }}?name=$PEX_FILENAME\ + \ \\\n --data-binary \"@dist/src.python.pants/$PEX_FILENAME\"\n\nWHL=$(find\ + \ dist/deploy/wheels/pantsbuild.pants -type f -name \"pantsbuild.pants-*.whl\"\ )\ncurl -L --fail \\\n -X POST \\\n -H \"Authorization: Bearer ${{ github.token\ \ }}\" \\\n -H \"Content-Type: application/octet-stream\" \\\n \"${{\ \ needs.release_info.outputs.release-asset-upload-url }}?name=$(basename $WHL)\"\ diff --git a/src/python/pants_release/generate_github_workflows.py b/src/python/pants_release/generate_github_workflows.py index 0563147320d..7bfcfff695f 100644 --- a/src/python/pants_release/generate_github_workflows.py +++ b/src/python/pants_release/generate_github_workflows.py @@ -932,8 +932,13 @@ def build_wheels_job( "if": "needs.release_info.outputs.is-release == 'true'", "run": dedent( """\ + PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import pants.version;print(pants.version.VERSION)") + PY_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import sys;print(f'cp{sys.version_info[0]}{sys.version_info[1]}')") + PLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import os;print(f'{os.uname().sysname.lower()}_{os.uname().machine.lower()}')") PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex + mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME + echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" """ ), }, @@ -956,11 +961,6 @@ def build_wheels_job( # support. `curl` is a good lowest-common-denominator way to upload the assets. "run": dedent( """\ - PANTS_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import pants.version;print(pants.version.VERSION)") - PY_VER=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import sys;print(f'cp{sys.version_info[0]}{sys.version_info[1]}')") - PLAT=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import os;print(f'{os.uname().sysname.lower()}_{os.uname().machine.lower()}')") - PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex - curl -L --fail \\ -X POST \\ -H "Authorization: Bearer ${{ github.token }}" \\ From fefd2c112446a5ea51e58947852e31f0d79b9489 Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Mon, 17 Feb 2025 18:21:12 -0500 Subject: [PATCH 2/2] better way to set env var in GHA --- .github/workflows/release.yaml | 8 ++++---- src/python/pants_release/generate_github_workflows.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bd54c60b247..790f18f6df6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -97,7 +97,7 @@ jobs: mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME - echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + echo "PEX_FILENAME=$PEX_FILENAME" | tee -a "$GITHUB_ENV" ' - continue-on-error: true @@ -211,7 +211,7 @@ jobs: mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME - echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + echo "PEX_FILENAME=$PEX_FILENAME" | tee -a "$GITHUB_ENV" ' - continue-on-error: true @@ -354,7 +354,7 @@ jobs: mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME - echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + echo "PEX_FILENAME=$PEX_FILENAME" | tee -a "$GITHUB_ENV" ' - continue-on-error: true @@ -480,7 +480,7 @@ jobs: mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME - echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + echo "PEX_FILENAME=$PEX_FILENAME" | tee -a "$GITHUB_ENV" ' - continue-on-error: true diff --git a/src/python/pants_release/generate_github_workflows.py b/src/python/pants_release/generate_github_workflows.py index 7bfcfff695f..20e7ec23d4b 100644 --- a/src/python/pants_release/generate_github_workflows.py +++ b/src/python/pants_release/generate_github_workflows.py @@ -938,7 +938,7 @@ def build_wheels_job( PEX_FILENAME=pants.$PANTS_VER-$PY_VER-$PLAT.pex mv dist/src.python.pants/pants-pex.pex dist/src.python.pants/$PEX_FILENAME - echo "PEX_FILENAME=$PEX_FILENAME" >> "$GITHUB_ENV" + echo "PEX_FILENAME=$PEX_FILENAME" | tee -a "$GITHUB_ENV" """ ), },