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

github: Fix attest invalid image name #114

Merged
merged 1 commit into from
Aug 30, 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
24 changes: 20 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ jobs:
username: ${{ secrets.DOCKER_ACCOUNT_ID }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Generate next docker tag
- name: Generate metadata for Docker
# NOTE: The tag contains the full docker container name + tag as it is requested
# by the build-and-push step.
run: |
REGISTRY=$(./docker.sh print-registry)
echo "REGISTRY=${REGISTRY}" >> $GITHUB_ENV
echo "Registry to be published is: ${REGISTRY}"

IMAGE_NAME=$(./docker.sh print-image-name)
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "Image name to be published is: ${IMAGE_NAME}"

NEXT_VERSION=$(./docker.sh print-next-version)
echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
echo "Next version to be published is: ${NEXT_VERSION}"
Expand All @@ -68,7 +76,7 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
uses: actions/attest-build-provenance@v1
with:
subject-name: index.docker.io/${{ env.VERSION }}
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build-and-push.outputs.digest }}
push-to-registry: true

Expand All @@ -95,8 +103,16 @@ jobs:
username: ${{ secrets.DOCKER_ACCOUNT_ID }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}

- name: Generate next docker tag
- name: Generate metadata for Docker
run: |
REGISTRY=$(./docker.sh print-registry)
echo "REGISTRY=${REGISTRY}" >> $GITHUB_ENV
echo "Registry to be published is: ${REGISTRY}"

IMAGE_NAME=$(./docker.sh print-image-name)
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "Image name to be published is: ${IMAGE_NAME}"

NEXT_VERSION=$(./docker.sh print-next-version)
echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
echo "Next version to be published is: ${NEXT_VERSION}"
Expand All @@ -117,6 +133,6 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
uses: actions/attest-build-provenance@v1
with:
subject-name: index.docker.io/${{ env.VERSION }}-riscv
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build-and-push-riscv.outputs.digest }}
push-to-registry: true
21 changes: 18 additions & 3 deletions docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ set -e
ARCH=$(uname -m)
GIT_COMMIT=$(git rev-parse HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
DOCKER_TAG=rustvmm/dev
IMAGE_NAME=rustvmm/dev
REGISTRY=index.docker.io

# Get the latest published version. Returns a number.
# If latest is v100, returns 100.
Expand All @@ -25,11 +26,19 @@ print_next_version() {
echo "rustvmm/dev:v$(next_version)"
roypat marked this conversation as resolved.
Show resolved Hide resolved
}

print_registry() {
echo ${REGISTRY}
}

print_image_name() {
echo ${IMAGE_NAME}
}

# Builds the tag for the newest versions. It needs the last published version number.
# Returns a valid docker tag.
build_tag(){
new_version=$(next_version)
new_tag=${DOCKER_TAG}:v${new_version}_$ARCH
new_tag=${IMAGE_NAME}:v${new_version}_$ARCH
echo "$new_tag"
}

Expand All @@ -49,7 +58,7 @@ build(){
manifest(){
latest_version=$(latest)
new_version=$((latest_version + 1))
new_tag=${DOCKER_TAG}:v${new_version}
new_tag=${IMAGE_NAME}:v${new_version}
docker manifest create \
$new_tag \
"${new_tag}_x86_64" \
Expand All @@ -76,6 +85,12 @@ case $1 in
"manifest")
manifest;
;;
"print-registry")
print_registry;
;;
"print-image-name")
print_image_name;
;;
"print-next-version")
print_next_version;
;;
Expand Down
Loading