Skip to content

chore: deploy with version like tags #1626

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

Merged
merged 6 commits into from
Jun 8, 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
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
paths:
- ".github/workflows/build.yml"
- "docker/**"
- "build.sh"
- "*.sh"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -46,6 +46,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 50

- name: Set up emulation
if: matrix.platform != 'i686' && matrix.platform != 'x86_64'
Expand All @@ -67,6 +69,9 @@ jobs:
- name: Build
run: ./build.sh

- name: Deploy (dry-run)
run: ./deploy.sh --dry-run

- name: Deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'pypa/manylinux'
run: ./deploy.sh
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ script: |
if [ "${MANYLINUX_BUILD_FRONTEND}" != "docker" ]; then
cp -rlf ./.buildx-cache-* ${HOME}/buildx-cache/
fi
COMMIT_SHA=${TRAVIS_COMMIT} ./deploy.sh --dry-run

deploy:
provider: script
Expand Down
41 changes: 33 additions & 8 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
#!/bin/bash
tag="quay.io/pypa/${POLICY}_${PLATFORM}"
build_id=$(git show -s --format=%cd-%h --date=short ${COMMIT_SHA})

docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
docker tag ${tag}:${COMMIT_SHA} ${tag}:${build_id}
docker tag ${tag}:${COMMIT_SHA} ${tag}:latest
docker push ${tag}:${build_id}
docker push ${tag}:latest

set -euo pipefail

export TZ=UTC0

DRY_RUN=0
if [ "${1:-}" == "--dry-run" ]; then
DRY_RUN=1
set -x
fi

TAG="quay.io/pypa/${POLICY}_${PLATFORM}"
COMMIT_ABBREV_SHA=$(git show -s --format=%h ${COMMIT_SHA})
COMMIT_DATE=$(git show -s --format=%cd --date=short ${COMMIT_SHA})
BUILD_ID=${COMMIT_DATE}-${COMMIT_ABBREV_SHA}
# Dependabot does not work with the BUILD_ID format
# Use a version like tag
if $(git rev-parse --is-shallow-repository); then
git fetch --shallow-since=${COMMIT_DATE}T00:00:00Z --all
fi
BUILD_NUMBER=$(git rev-list --since=${COMMIT_DATE}T00:00:00Z --count ${COMMIT_SHA})
BUILD_ID2=${COMMIT_DATE//-/.}.${BUILD_NUMBER}

docker tag ${TAG}:${COMMIT_SHA} ${TAG}:${BUILD_ID}
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:${BUILD_ID2}
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:latest

if [ $DRY_RUN -eq 0 ]; then
docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
docker push ${TAG}:${BUILD_ID}
docker push ${TAG}:${BUILD_ID2}
docker push ${TAG}:latest
fi