From 8bd035f51d9f754be00ce810bcf35151af7105a9 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 7 Oct 2019 02:43:28 +0700 Subject: [PATCH 1/7] ci(github): renew trigger definition There is an update in workflow syntax docs https://help.github.com/en/articles/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e84cefd3ab..34c40d5ced 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,7 +2,7 @@ name: Publish consumable Docker images on: push: - tags: ['*.*.*'] + tags: ['v?[0-9]+.[0-9]+.[0-9]+*'] jobs: compile: From b1637751124eb970b849465303a1d6f080e4b563 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 7 Oct 2019 02:53:23 +0700 Subject: [PATCH 2/7] =?UTF-8?q?ci(github):=20install=20cross=20from=20rele?= =?UTF-8?q?ase=20page=20=E2=9A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of compiling `cross` via `cargo install`, downloading binary executable from release page will speedup the CI --- .github/workflows/docker-publish.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 34c40d5ced..a0a027ff53 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -14,7 +14,11 @@ jobs: - x86_64-unknown-linux-gnu steps: - uses: actions/checkout@v1 - - run: cargo install cross + - name: Install rust-embedded/cross + env: { VERSION: v0.1.16 } + run: >- + wget -nv https://github.com/rust-embedded/cross/releases/download/${VERSION}/cross-${VERSION}-x86_64-unknown-linux-gnu.tar.gz + -O- | sudo tar xz -C /usr/local/bin/ - name: compile for specific target env: { arch: '${{ matrix.arch }}' } run: | From b13439431981b308ddea588144cb595883c30cca Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 7 Oct 2019 03:08:10 +0700 Subject: [PATCH 3/7] 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 From 93ae5043cc996f632e3de8de7fb383698016752e Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 7 Oct 2019 03:53:07 +0700 Subject: [PATCH 4/7] ci(github): change REGISTRY to quay.io --- .github/workflows/docker-publish.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 424d833b3a..d54ccea3b1 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -68,12 +68,13 @@ jobs: export PATCH=$([ ${{ matrix.use-patch }} = true ] && echo .${{ matrix.tag }} || echo '') chmod +x $NU_BINS - echo ${{ secrets.DOCKER_REGISTRY }} | docker login ${REGISTRY%%/*} -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: BASE_IMAGE: ${{ matrix.base-image }} - REGISTRY: docker.pkg.github.com/${{ github.repository }} + # REGISTRY: docker.pkg.github.com/${{ github.repository }} #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com + REGISTRY: quay.io/${{ github.actor }} #region semantics tagging - name: Retag and push without suffixing version @@ -95,7 +96,9 @@ jobs: # latest version docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${{ matrix.tag }} docker push ${REGISTRY,,}/nu:${{ matrix.tag }} - env: { REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' } + env: + # REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com + REGISTRY: quay.io/${{ github.actor }} - name: Retag and push debian as latest if: matrix.tag == 'debian' run: |- @@ -112,5 +115,7 @@ jobs: # latest version docker tag ${REGISTRY,,}/nu:${{ matrix.tag }} ${REGISTRY,,}/nu:latest docker push ${REGISTRY,,}/nu:latest - env: { REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' } + env: + # REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com + REGISTRY: quay.io/${{ github.actor }} #endregion semantics tagging From 3e14de158beea945dcfe6ea9aa2ac7e603be38c1 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Wed, 9 Oct 2019 09:58:49 +0700 Subject: [PATCH 5/7] fix(ci): can't push to quay.io (#1) * ci(github): lowercase ${{ github.actor }} * ci(github): fix robot username * fix(ci): fix tag name on suffixed version --- .github/workflows/docker-publish.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d54ccea3b1..0deca68a42 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -63,21 +63,22 @@ jobs: with: { name: '${{ matrix.arch }}', path: target/release } - name: Build and publish exact version run: |- - REGISTRY=${REGISTRY,,}; export TAG=${GITHUB_REF##*/}-${{ matrix.tag }}; + 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 ${REGISTRY%/*} -u ${{ github.actor }} --password-stdin + echo ${{ secrets.DOCKER_REGISTRY }} | docker login ${REGISTRY%/*} -u ${USER,,} --password-stdin docker-compose --file docker/docker-compose.package.yml build docker-compose --file docker/docker-compose.package.yml push # exact version env: BASE_IMAGE: ${{ matrix.base-image }} # REGISTRY: docker.pkg.github.com/${{ github.repository }} #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com + USER: ${{ github.actor }}+action REGISTRY: quay.io/${{ github.actor }} #region semantics tagging - - name: Retag and push without suffixing version + - name: Retag and push with suffixed version run: |- VERSION=${GITHUB_REF##*/} @@ -86,7 +87,7 @@ jobs: latest_patch=${VERSION%.*}-${{ matrix.tag }} exact_version=${VERSION}-${{ matrix.tag }} - tags=( latest_version latest_feature latest_patch exact_version ) + tags=( ${latest_version} ${latest_feature} ${latest_patch} ${exact_version} ) for tag in ${tags[@]}; do docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${tag} From 7cf3c6eb951772322cab00f6084c3fd9d730c535 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Mon, 11 Nov 2019 07:51:41 +0700 Subject: [PATCH 6/7] Move env declaration to jobs.docker --- .github/workflows/docker-publish.yml | 34 ++++++++++++---------------- docker/docker-compose.package.yml | 2 +- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0deca68a42..ef731e26c6 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -35,6 +35,10 @@ jobs: name: Build and publish docker images needs: compile runs-on: ubuntu-latest + env: + DOCKER_REGISTRY: quay.io/nushell + DOCKER_PASSWORD: ${{ secrets.DOCKER_REGISTRY }} + DOCKER_USER: nushell+action # TBD strategy: matrix: tag: @@ -63,19 +67,16 @@ jobs: with: { name: '${{ matrix.arch }}', path: target/release } - name: Build and publish exact version run: |- - REGISTRY=${REGISTRY,,}; export TAG=${GITHUB_REF##*/}-${{ matrix.tag }} + export DOCKER_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 ${REGISTRY%/*} -u ${USER,,} --password-stdin + echo ${DOCKER_PASSWORD} | docker login ${DOCKER_REGISTRY} -u ${DOCKER_USER} --password-stdin docker-compose --file docker/docker-compose.package.yml build docker-compose --file docker/docker-compose.package.yml push # exact version env: BASE_IMAGE: ${{ matrix.base-image }} - # REGISTRY: docker.pkg.github.com/${{ github.repository }} #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com - USER: ${{ github.actor }}+action - REGISTRY: quay.io/${{ github.actor }} #region semantics tagging - name: Retag and push with suffixed version @@ -90,16 +91,14 @@ jobs: 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} + docker tag ${DOCKER_REGISTRY}/nu:${VERSION}-${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:${tag} + docker push ${DOCKER_REGISTRY}/nu:${tag} done # latest version - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${{ matrix.tag }} - docker push ${REGISTRY,,}/nu:${{ matrix.tag }} - env: - # REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com - REGISTRY: quay.io/${{ github.actor }} + docker tag ${DOCKER_REGISTRY}/nu:${VERSION}-${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:${{ matrix.tag }} + docker push ${DOCKER_REGISTRY}/nu:${{ matrix.tag }} + - name: Retag and push debian as latest if: matrix.tag == 'debian' run: |- @@ -109,14 +108,11 @@ jobs: tags=( ${VERSION%%.*} ${VERSION%.*} ${VERSION} ) for tag in ${tags[@]}; do - docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${tag} - docker push ${REGISTRY,,}/nu:${tag} + docker tag ${DOCKER_REGISTRY}/nu:${VERSION}-${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:${tag} + docker push ${DOCKER_REGISTRY}/nu:${tag} done # latest version - docker tag ${REGISTRY,,}/nu:${{ matrix.tag }} ${REGISTRY,,}/nu:latest - docker push ${REGISTRY,,}/nu:latest - env: - # REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' #TODO: waiting support for GITHUB_TOKEN for docker.pkg.github.com - REGISTRY: quay.io/${{ github.actor }} + docker tag ${DOCKER_REGISTRY}/nu:${{ matrix.tag }} ${DOCKER_REGISTRY}/nu:latest + docker push ${DOCKER_REGISTRY}/nu:latest #endregion semantics tagging diff --git a/docker/docker-compose.package.yml b/docker/docker-compose.package.yml index 9be36544eb..a2ad90b6bb 100644 --- a/docker/docker-compose.package.yml +++ b/docker/docker-compose.package.yml @@ -2,7 +2,7 @@ version: '3' services: nushell: - image: ${REGISTRY}/nu:${TAG} + image: ${DOCKER_REGISTRY}/nu:${DOCKER_TAG} build: context: .. dockerfile: docker/Package${PATCH}.Dockerfile From f3d056110a8cb038baf38795749e0cc869506aba Mon Sep 17 00:00:00 2001 From: Vanessasaurus Date: Mon, 11 Nov 2019 13:33:52 -0500 Subject: [PATCH 7/7] DOCKER_USER should come from secrets --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ef731e26c6..f803d6e343 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -38,7 +38,7 @@ jobs: env: DOCKER_REGISTRY: quay.io/nushell DOCKER_PASSWORD: ${{ secrets.DOCKER_REGISTRY }} - DOCKER_USER: nushell+action # TBD + DOCKER_USER: ${{ secrets.DOCKER_USER }} strategy: matrix: tag: