forked from pypa/gh-action-pypi-publish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Up to this point, the project has been set up as a Docker action referencing the Dockerfile. The downside to using the Dockerfile for the action is that the Docker image must be built every time the action is used. This commit will set up the project to build the Docker image and push it to GitHub Container Registry (GHCR). This change will speed up user workflows every time the action is used because the workflows will simply pull the Docker image from GHCR instead of building again. Changes: - Add required metadata to Dockerfile - Build container image with GitHub Actions - Push container image to GHCR Docker actions support pulling in pre-built Docker images. The downside is that there's no way to specify the correct Docker tag because the GitHub Actions `image` and `uses:` keys don't accept any context. For example, if a user's workflow has `uses: pypa/gh-action-pypi-publish@release/v1.8`, then the action should pull in a Docker image built from the `release/v1.8` branch, something like `ghcr.io/pypa/gh-action-pypi-publish:release-v1.8` (Docker tags can't have `/`). The workaround is to switch the top-level `action.yml` to a composite action that then calls the Docker action, substituting the correct image name and tag.
- Loading branch information
1 parent
699cd61
commit 9756850
Showing
5 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: 🏃 | ||
inputs: | ||
user: | ||
required: false | ||
password: | ||
required: false | ||
repository-url: | ||
required: false | ||
packages-dir: | ||
required: false | ||
verify-metadata: | ||
required: false | ||
skip-existing: | ||
required: false | ||
verbose: | ||
required: false | ||
print-hash: | ||
required: false | ||
runs: | ||
using: docker | ||
image: {{image}} | ||
args: | ||
- ${{ inputs.user }} | ||
- ${{ inputs.password }} | ||
- ${{ inputs.repository-url }} | ||
- ${{ inputs.packages-dir }} | ||
- ${{ inputs.verify-metadata }} | ||
- ${{ inputs.skip-existing }} | ||
- ${{ inputs.verbose }} | ||
- ${{ inputs.print-hash }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
|
||
name: 🏗️ | ||
|
||
on: # yamllint disable-line rule:truthy | ||
pull_request: | ||
push: | ||
branches: ["release/*", "unstable/*"] | ||
tags: ["*"] | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build Docker image | ||
run: | | ||
IMAGE="ghcr.io/$GITHUB_REPOSITORY:${GITHUB_REF_NAME/'/'/'-'}" | ||
echo "IMAGE=$IMAGE" >>"$GITHUB_ENV" | ||
docker build . \ | ||
--build-arg BUILDKIT_INLINE_CACHE=1 \ | ||
--cache-from $IMAGE \ | ||
--tag $IMAGE | ||
- name: Push Docker image to GHCR | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
echo ${{ secrets.GITHUB_TOKEN }} | | ||
docker login ghcr.io -u $GITHUB_ACTOR --password-stdin | ||
docker push $IMAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ FROM python:3.12-slim | |
LABEL "maintainer" "Sviatoslav Sydorenko <[email protected]>" | ||
LABEL "repository" "https://github.com/pypa/gh-action-pypi-publish" | ||
LABEL "homepage" "https://github.com/pypa/gh-action-pypi-publish" | ||
LABEL "org.opencontainers.image.source" "https://github.com/pypa/gh-action-pypi-publish" | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters