From 912e3a30c1060f62d0e74e466e23290f738ce877 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli Date: Fri, 13 Dec 2024 11:32:40 +0000 Subject: [PATCH] ci: fixup release process (#1580) --- .github/workflows/publish_to_pypi.yml | 38 ++++++--------------------- docs/security.md | 4 +-- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml index 62d08aeef..9004a10bc 100644 --- a/.github/workflows/publish_to_pypi.yml +++ b/.github/workflows/publish_to_pypi.yml @@ -2,7 +2,6 @@ # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#the-whole-ci-cd-workflow # but with the following differences # - removed the TestPyPI part -# - sanitise the `github.ref_name` part # - instead of `on: push`, we have `tags` in there too name: Publish Python 🐍 distribution 📦 to PyPI @@ -85,38 +84,17 @@ jobs: - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} - run: | - # Sanitize ref_name by removing unsafe characters - SAFE_REF_NAME=$(echo '${{ github.ref_name }}' | tr -cd '[:alnum:]-_') - - # Validate that the sanitized name is not empty (to avoid invalid input) - if [ -z "$SAFE_REF_NAME" ]; then - echo "Sanitized reference name is empty. Exiting." - exit 1 - fi - - # Use the sanitized name in the gh command - gh release create \ - "$SAFE_REF_NAME" \ - --repo '${{ github.repository }}' \ - --notes "" + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" - name: Upload artifact signatures to GitHub Release env: GITHUB_TOKEN: ${{ github.token }} # Upload to GitHub Release using the `gh` CLI. # `dist/` contains the built packages, and the # sigstore-produced signatures and certificates. - run: | - # Sanitize ref_name by removing unsafe characters - SAFE_REF_NAME=$(echo '${{ github.ref_name }}' | tr -cd '[:alnum:]-_') - - # Validate that the sanitized name is not empty (to avoid invalid input) - if [ -z "$SAFE_REF_NAME" ]; then - echo "Sanitized reference name is empty. Exiting." - exit 1 - fi - - # Use the sanitized name in the gh command - gh release upload \ - "$SAFE_REF_NAME" dist/** \ - --repo '${{ github.repository }}' + run: >- + gh release upload + '${{ github.ref_name }}' dist/** diff --git a/docs/security.md b/docs/security.md index d1b518bea..43ad6dcf0 100644 --- a/docs/security.md +++ b/docs/security.md @@ -5,8 +5,8 @@ good security practices. Here are some practices we follow: - We publish to PyPI via trusted publishing and are PEP740-compliant. - We don't use `pull_request_target` in any CI job. -- We sanitise the (potentially unsafe) `github.ref_name` variable when publishing - releases. +- The release CI job can only be triggered for tag pushes, and only + Narwhals members with release permissions (see below) can push tags. - All members of `narwhals-dev` are required to have two-factor authentication enabled. - There are no binary or opaque files in the Narwhals repository.