From da55fbfefa8863e6bd873984bc11ba901be8e8c3 Mon Sep 17 00:00:00 2001 From: Yurii Puchkov Date: Wed, 27 Dec 2023 14:24:37 -0700 Subject: [PATCH] feat(CICD): Add pip build and push to the build steps --- .github/workflows/build.yaml | 38 +++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0a0108a..567f7b5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,9 +44,11 @@ jobs: build: runs-on: ubuntu-latest needs: unittests - if: github.ref == 'refs/heads/main' + # if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 + with: + fetch-depth: 10 - name: Docker Build shell: bash @@ -61,13 +63,35 @@ jobs: username: ${{ env.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Docker Push + - name: Detect package version shell: bash run: | set -x - DOCKER_TAG="$(git tag --contains)" - if [[ "${DOCKER_TAG}" == "" ]]; then - DOCKER_TAG="latest" + PACKAGE_VERSION="$(git tag --contains)" + if [[ "${PACKAGE_VERSION}" == "" ]]; then + PACKAGE_VERSION="$(docker run --rm -v $(pwd):/app -w /app --user "$(id -u):$(id -g)" panpuchkov/pygitver --next-ver)-dev" + DOCKER_TAG_LATEST="PACKAGE_VERSION" + else + DOCKER_TAG_LATEST="latest" fi - IMAGE_NAME_WITH_VERSION="${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${DOCKER_TAG}" - docker push "${IMAGE_NAME_WITH_VERSION}" + + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + echo "DOCKER_TAG_LATEST=$DOCKER_TAG_LATEST" >> $GITHUB_ENV + + - name: Docker Push + shell: bash + run: | + set -x + IMAGE_NAME_WITH_TAG_VERSION="${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${PACKAGE_VERSION}" + IMAGE_NAME_WITH_TAG_LATEST="${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${DOCKER_TAG_LATEST}" + echo "IMAGE_NAME_WITH_TAG_VERSION: ${IMAGE_NAME_WITH_TAG_VERSION}" + echo "IMAGE_NAME_WITH_TAG_LATEST: ${IMAGE_NAME_WITH_TAG_LATEST}" + # docker push "${IMAGE_NAME_WITH_TAG_VERSION}" + # docker push "${IMAGE_NAME_WITH_TAG_LATEST}" + + - name: Pip Build & Push + shell: bash + run: | + set -x + pip install -r requirements-build.txt + python -m build