Skip to content

Commit dd24f6e

Browse files
authored
chore: deploy with version like tags (pypa#1626)
1 parent 92884f7 commit dd24f6e

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
paths:
2020
- ".github/workflows/build.yml"
2121
- "docker/**"
22-
- "build.sh"
22+
- "*.sh"
2323

2424
concurrency:
2525
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
@@ -46,6 +46,8 @@ jobs:
4646
steps:
4747
- name: Checkout
4848
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 50
4951

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

72+
- name: Deploy (dry-run)
73+
run: ./deploy.sh --dry-run
74+
7075
- name: Deploy
7176
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'pypa/manylinux'
7277
run: ./deploy.sh

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ script: |
8181
if [ "${MANYLINUX_BUILD_FRONTEND}" != "docker" ]; then
8282
cp -rlf ./.buildx-cache-* ${HOME}/buildx-cache/
8383
fi
84+
COMMIT_SHA=${TRAVIS_COMMIT} ./deploy.sh --dry-run
8485
8586
deploy:
8687
provider: script

deploy.sh

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
#!/bin/bash
2-
tag="quay.io/pypa/${POLICY}_${PLATFORM}"
3-
build_id=$(git show -s --format=%cd-%h --date=short ${COMMIT_SHA})
4-
5-
docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
6-
docker tag ${tag}:${COMMIT_SHA} ${tag}:${build_id}
7-
docker tag ${tag}:${COMMIT_SHA} ${tag}:latest
8-
docker push ${tag}:${build_id}
9-
docker push ${tag}:latest
2+
3+
set -euo pipefail
4+
5+
export TZ=UTC0
6+
7+
DRY_RUN=0
8+
if [ "${1:-}" == "--dry-run" ]; then
9+
DRY_RUN=1
10+
set -x
11+
fi
12+
13+
TAG="quay.io/pypa/${POLICY}_${PLATFORM}"
14+
COMMIT_ABBREV_SHA=$(git show -s --format=%h ${COMMIT_SHA})
15+
COMMIT_DATE=$(git show -s --format=%cd --date=short ${COMMIT_SHA})
16+
BUILD_ID=${COMMIT_DATE}-${COMMIT_ABBREV_SHA}
17+
# Dependabot does not work with the BUILD_ID format
18+
# Use a version like tag
19+
if $(git rev-parse --is-shallow-repository); then
20+
git fetch --shallow-since=${COMMIT_DATE}T00:00:00Z --all
21+
fi
22+
BUILD_NUMBER=$(git rev-list --since=${COMMIT_DATE}T00:00:00Z --count ${COMMIT_SHA})
23+
BUILD_ID2=${COMMIT_DATE//-/.}.${BUILD_NUMBER}
24+
25+
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:${BUILD_ID}
26+
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:${BUILD_ID2}
27+
docker tag ${TAG}:${COMMIT_SHA} ${TAG}:latest
28+
29+
if [ $DRY_RUN -eq 0 ]; then
30+
docker login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
31+
docker push ${TAG}:${BUILD_ID}
32+
docker push ${TAG}:${BUILD_ID2}
33+
docker push ${TAG}:latest
34+
fi

0 commit comments

Comments
 (0)