From b13439431981b308ddea588144cb595883c30cca Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 7 Oct 2019 03:08:10 +0700 Subject: [PATCH] ci(github): refactor docker related run scripts --- .github/workflows/docker-publish.yml | 46 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a0a027ff53..424d833b3a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -62,13 +62,13 @@ jobs: - uses: actions/download-artifact@master with: { name: '${{ matrix.arch }}', path: target/release } - name: Build and publish exact version - run: | + run: |- REGISTRY=${REGISTRY,,}; export TAG=${GITHUB_REF##*/}-${{ matrix.tag }}; export NU_BINS=target/release/$( [ ${{ matrix.plugin }} = true ] && echo nu* || echo nu ) export PATCH=$([ ${{ matrix.use-patch }} = true ] && echo .${{ matrix.tag }} || echo '') chmod +x $NU_BINS - echo ${{ secrets.DOCKER_REGISTRY }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + echo ${{ secrets.DOCKER_REGISTRY }} | docker login ${REGISTRY%%/*} -u ${{ github.actor }} --password-stdin docker-compose --file docker/docker-compose.package.yml build docker-compose --file docker/docker-compose.package.yml push # exact version env: @@ -77,26 +77,40 @@ jobs: #region semantics tagging - name: Retag and push without suffixing version - run: | + run: |- VERSION=${GITHUB_REF##*/} + + latest_version=${VERSION%%%.*}-${{ matrix.tag }} + latest_feature=${VERSION%%.*}-${{ matrix.tag }} + latest_patch=${VERSION%.*}-${{ matrix.tag }} + exact_version=${VERSION}-${{ matrix.tag }} + + tags=( latest_version latest_feature latest_patch exact_version ) + + for tag in ${tags[@]}; do + docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${tag} + docker push ${REGISTRY,,}/nu:${tag} + done + + # latest version docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${{ matrix.tag }} - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%%.*}-${{ matrix.tag }} - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%.*}-${{ matrix.tag }} - docker push ${REGISTRY,,}/nu:${VERSION%.*}-${{ matrix.tag }} # latest patch - docker push ${REGISTRY,,}/nu:${VERSION%%.*}-${{ matrix.tag }} # latest features - docker push ${REGISTRY,,}/nu:${{ matrix.tag }} # latest version + docker push ${REGISTRY,,}/nu:${{ matrix.tag }} env: { REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' } - name: Retag and push debian as latest if: matrix.tag == 'debian' - run: | + run: |- VERSION=${GITHUB_REF##*/} + + # ${latest features} ${latest patch} ${exact version} + tags=( ${VERSION%%.*} ${VERSION%.*} ${VERSION} ) + + for tag in ${tags[@]}; do + docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${tag} + docker push ${REGISTRY,,}/nu:${tag} + done + + # latest version docker tag ${REGISTRY,,}/nu:${{ matrix.tag }} ${REGISTRY,,}/nu:latest - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%.*} - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%%.*} - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION} - docker push ${REGISTRY,,}/nu:${VERSION} # exact version - docker push ${REGISTRY,,}/nu:${VERSION%%.*} # latest features - docker push ${REGISTRY,,}/nu:${VERSION%.*} # latest patch - docker push ${REGISTRY,,}/nu:latest # latest version + docker push ${REGISTRY,,}/nu:latest env: { REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' } #endregion semantics tagging