Skip to content

Commit

Permalink
chore: update release workflow to publish PyPI package as a Trusted P…
Browse files Browse the repository at this point in the history
…ublisher (#190)
  • Loading branch information
blidd-google committed Apr 9, 2024
1 parent 54d0b80 commit a9a7b47
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .github/scripts/publish_preflight_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true >---
git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
echo ""

readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/v${RELEASE_VERSION}"` || true
readonly EXISTING_TAG=`git rev-parse -q --verify "refs/tags/${RELEASE_VERSION}"` || true
if [[ -n "${EXISTING_TAG}" ]]; then
echo_warn "Tag v${RELEASE_VERSION} already exists. Exiting."
echo_warn "Tag ${RELEASE_VERSION} already exists. Exiting."
echo_warn "If the tag was created in a previous unsuccessful attempt, delete it and try again."
echo_warn " $ git tag -d v${RELEASE_VERSION}"
echo_warn " $ git push --delete origin v${RELEASE_VERSION}"
echo_warn " $ git tag -d ${RELEASE_VERSION}"
echo_warn " $ git push --delete origin ${RELEASE_VERSION}"

readonly RELEASE_URL="https://github.com/firebase/firebase-functions-python/releases/tag/v${RELEASE_VERSION}"
readonly RELEASE_URL="https://github.com/firebase/firebase-functions-python/releases/tag/${RELEASE_VERSION}"
echo_warn "Delete any corresponding releases at ${RELEASE_URL}."
terminate
fi

echo_info "Tag v${RELEASE_VERSION} does not exist."
echo_info "Tag ${RELEASE_VERSION} does not exist."


echo_info ""
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@ jobs:
runs-on: ubuntu-latest

permissions:
# Used to create a short-lived OIDC token which is given to PyPi to identify this workflow job
# See: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
# and https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
contents: write

steps:
- name: Checkout source for publish
uses: actions/checkout@v3
uses: actions/checkout@v4

# Download the artifacts created by the stage_release job.
- name: Download release candidates
Expand Down Expand Up @@ -113,6 +120,3 @@ jobs:

- name: Publish to Pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: firebase
password: ${{ secrets.PYPI_PASSWORD }}

0 comments on commit a9a7b47

Please sign in to comment.