Skip to content

Commit a9a7b47

Browse files
authored
chore: update release workflow to publish PyPI package as a Trusted Publisher (#190)
1 parent 54d0b80 commit a9a7b47

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

.github/scripts/publish_preflight_check.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,19 @@ echo_info "---< git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true >---
138138
git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
139139
echo ""
140140

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

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

153-
echo_info "Tag v${RELEASE_VERSION} does not exist."
153+
echo_info "Tag ${RELEASE_VERSION} does not exist."
154154

155155

156156
echo_info ""

.github/workflows/release.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,16 @@ jobs:
8080
8181
runs-on: ubuntu-latest
8282

83+
permissions:
84+
# Used to create a short-lived OIDC token which is given to PyPi to identify this workflow job
85+
# See: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
86+
# and https://docs.pypi.org/trusted-publishers/using-a-publisher/
87+
id-token: write
88+
contents: write
89+
8390
steps:
8491
- name: Checkout source for publish
85-
uses: actions/checkout@v3
92+
uses: actions/checkout@v4
8693

8794
# Download the artifacts created by the stage_release job.
8895
- name: Download release candidates
@@ -113,6 +120,3 @@ jobs:
113120

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

0 commit comments

Comments
 (0)