Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update release workflow to publish PyPI package as a Trusted Publisher #190

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading