From d65faff7f151680dc959b9d8c61b82a81579ec3d Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 12 Sep 2021 18:39:02 +0000 Subject: [PATCH 1/6] Enhancement (development): Add .vscode/tasks.json --- .gitignore | 1 + .vscode/tasks.json | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index c7fe8eb..b60a7bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.* !/.gitignore !/.github +!/.vscode diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5d409e9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,30 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Generate-DockerImageVariants", + "type": "process", + "command": "pwsh", + "args": [ + "-c", + "Generate-DockerImageVariants ." + ], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Install DockerImageVariants module", + "type": "process", + "command": "pwsh", + "args": [ + "-c", + "Install-Module -Name Generate-DockerImageVariants -Repository PSGallery -Scope CurrentUser -Force -Verbose" + ], + "group": "build" + } + ] +} From f6f3fe8b07ed640666146a961884dc5c775cedff Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 12 Sep 2021 18:45:15 +0000 Subject: [PATCH 2/6] Refactor (ci): Remove .github/workflows/ci-release and use only ci-master-pr and CalVer-based workflow --- .github/release-drafter.yml | 52 + .github/workflows/ci-master-pr.yml | 1337 ++++++++++++++--- .github/workflows/ci-release.yml | 593 -------- generate/definitions/FILES.ps1 | 3 +- .../templates/.github/release-drafter.yml.ps1 | 54 + .../.github/workflows/ci-master-pr.yml.ps1 | 238 ++- .../.github/workflows/ci-release.yml.ps1 | 90 -- 7 files changed, 1476 insertions(+), 891 deletions(-) create mode 100644 .github/release-drafter.yml delete mode 100644 .github/workflows/ci-release.yml create mode 100644 generate/templates/.github/release-drafter.yml.ps1 delete mode 100644 generate/templates/.github/workflows/ci-release.yml.ps1 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..cd59642 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,52 @@ +# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. +name-template: '$RESOLVED_VERSION 🌈' +tag-template: '$RESOLVED_VERSION' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🖊️ Refactors' + labels: + - 'refactor' + - title: '👗 Style' + labels: + - 'style' + - title: '📝 Documentation' + labels: + - 'docs' + - 'documentation' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +version-resolver: + major: + labels: + # - 'major' + - 'breaking' + minor: + labels: + # - 'minor' + - 'feature' + - 'enhancement' + - 'refactor' + patch: + labels: + # - 'patch' + - 'fix' + - 'bugfix' + - 'bug' + - 'style' + - 'docs' + - 'documentation' + default: patch +sort-by: title +template: | + ## Changes + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index 2cbebca..6ce7eef 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -4,19 +4,22 @@ on: push: branches: - master + - release # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. pull_request: branches: - master - jobs: + build-v3-0-8-alpine-3-13: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.8-alpine-3.13 # VARIANT_TAG_WITH_REF: v3.0.8-alpine-3.13-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.8-alpine-3.13 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -29,45 +32,125 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + ${{ github.repository }}:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-7-alpine-3-12: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.7-alpine-3.12 # VARIANT_TAG_WITH_REF: v3.0.7-alpine-3.12-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.7-alpine-3.12 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -80,45 +163,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-6-alpine-3-11: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.6-alpine-3.11 # VARIANT_TAG_WITH_REF: v3.0.6-alpine-3.11-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.6-alpine-3.11 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -131,45 +293,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-6-alpine-3-10: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.6-alpine-3.10 # VARIANT_TAG_WITH_REF: v3.0.6-alpine-3.10-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.6-alpine-3.10 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -182,45 +423,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-5-alpine-3-9: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.5-alpine-3.9 # VARIANT_TAG_WITH_REF: v3.0.5-alpine-3.9-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.5-alpine-3.9 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -233,45 +553,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-4-alpine-3-8: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.4-alpine-3.8 # VARIANT_TAG_WITH_REF: v3.0.4-alpine-3.8-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.4-alpine-3.8 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -284,45 +683,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-3-alpine-3-7: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.3-alpine-3.7 # VARIANT_TAG_WITH_REF: v3.0.3-alpine-3.7-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.3-alpine-3.7 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -335,45 +813,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-1-alpine-3-6: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.1-alpine-3.6 # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.6-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.6 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -386,45 +943,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-1-alpine-3-5: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.1-alpine-3.5 # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.5-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.5 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -437,45 +1073,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-1-alpine-3-4: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.1-alpine-3.4 # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.4-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.4 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -488,45 +1203,124 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() + build-v3-0-1-alpine-3-3: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: v3.0.1-alpine-3.3 # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.3-${GITHUB_REF} VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.3 steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -539,34 +1333,199 @@ jobs: pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout - if: always() \ No newline at end of file + if: always() + + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + converge-master-and-release-branches: + needs: [build-v3-0-8-alpine-3-13, build-v3-0-7-alpine-3-12, build-v3-0-6-alpine-3-11, build-v3-0-6-alpine-3-10, build-v3-0-5-alpine-3-9, build-v3-0-4-alpine-3-8, build-v3-0-3-alpine-3-7, build-v3-0-1-alpine-3-6, build-v3-0-1-alpine-3-5, build-v3-0-1-alpine-3-4, build-v3-0-1-alpine-3-3] + if: github.ref == 'refs/heads/release' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Merge release into master (fast-forward) + run: | + git checkout master + git merge release + git push origin master + + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + resolve-release-tag: + runs-on: ubuntu-latest + outputs: + TAG: ${{ steps.resolve-release-tag.outputs.TAG }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Resolve release tag + id: resolve-release-tag + run: | + set +e + # E.g. 20210402 + TODAYS_DATE=$( date -u '+%Y%m%d' ) + # Is this the first tag for this date? + TODAYS_DATE_TAGS=$( git tag --list | grep "^$TODAYS_DATE" ) + TAG= + if [ -z "$TODAYS_DATE_TAGS" ]; then + # E.g. 20210402.0.0 + TAG="$TODAYS_DATE.0.0" # Send this to stdout + else + # E.g. if there are 20210402.0.0, 20210402.0.1, 20210402.0.2, this returns 2 + VERSION_MINOR_LATEST=$( echo "$TODAYS_DATE_TAGS" | cut -d '.' -f 3 | sort -nr | head -n1 ) + # Minor version + VERSION_MINOR=$( expr "$VERSION_MINOR_LATEST" + 1 ) + # E.g. 20210402.0.3 + TAG="$TODAYS_DATE.0.$VERSION_MINOR" # Send this to stdout + fi + echo "TODAYS_DATE: $TODAYS_DATE" + echo "TODAYS_DATE_TAGS: $TODAYS_DATE_TAGS" + echo "TAG: $TAG" + echo "::set-output name=TAG::$TAG" + - name: Print outputs + run: echo ${{ steps.resolve-release-tag.outputs.TAG }} + + update-draft-release: + needs: [build-v3-0-8-alpine-3-13, build-v3-0-7-alpine-3-12, build-v3-0-6-alpine-3-11, build-v3-0-6-alpine-3-10, build-v3-0-5-alpine-3-9, build-v3-0-4-alpine-3-8, build-v3-0-3-alpine-3-7, build-v3-0-1-alpine-3-6, build-v3-0-1-alpine-3-5, build-v3-0-1-alpine-3-4, build-v3-0-1-alpine-3-3, resolve-release-tag] + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Print inputs + run: echo ${{ needs.resolve-release-tag.outputs.TAG }} + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: false + name: ${{ needs.resolve-release-tag.outputs.TAG }} + tag: ${{ needs.resolve-release-tag.outputs.TAG }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-draft-release: + needs: [build-v3-0-8-alpine-3-13, build-v3-0-7-alpine-3-12, build-v3-0-6-alpine-3-11, build-v3-0-6-alpine-3-10, build-v3-0-5-alpine-3-9, build-v3-0-4-alpine-3-8, build-v3-0-3-alpine-3-7, build-v3-0-1-alpine-3-6, build-v3-0-1-alpine-3-5, build-v3-0-1-alpine-3-4, build-v3-0-1-alpine-3-3, converge-master-and-release-branches, resolve-release-tag] + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: true + name: ${{ needs.resolve-release-tag.outputs.TAG }} + tag: ${{ needs.resolve-release-tag.outputs.TAG }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml deleted file mode 100644 index a437aac..0000000 --- a/.github/workflows/ci-release.yml +++ /dev/null @@ -1,593 +0,0 @@ -name: ci-release - -on: - push: - branches: - - release - -jobs: - build-v3-0-8-alpine-3-13: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.8-alpine-3.13 - # VARIANT_TAG_WITH_REF: v3.0.8-alpine-3.13-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.8-alpine-3.13 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:latest" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:latest" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-7-alpine-3-12: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.7-alpine-3.12 - # VARIANT_TAG_WITH_REF: v3.0.7-alpine-3.12-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.7-alpine-3.12 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-6-alpine-3-11: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.6-alpine-3.11 - # VARIANT_TAG_WITH_REF: v3.0.6-alpine-3.11-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.6-alpine-3.11 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-6-alpine-3-10: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.6-alpine-3.10 - # VARIANT_TAG_WITH_REF: v3.0.6-alpine-3.10-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.6-alpine-3.10 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-5-alpine-3-9: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.5-alpine-3.9 - # VARIANT_TAG_WITH_REF: v3.0.5-alpine-3.9-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.5-alpine-3.9 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-4-alpine-3-8: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.4-alpine-3.8 - # VARIANT_TAG_WITH_REF: v3.0.4-alpine-3.8-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.4-alpine-3.8 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-3-alpine-3-7: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.3-alpine-3.7 - # VARIANT_TAG_WITH_REF: v3.0.3-alpine-3.7-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.3-alpine-3.7 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-1-alpine-3-6: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.1-alpine-3.6 - # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.6-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.6 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-1-alpine-3-5: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.1-alpine-3.5 - # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.5-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.5 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-1-alpine-3-4: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.1-alpine-3.4 - # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.4-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.4 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() - build-v3-0-1-alpine-3-3: - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: v3.0.1-alpine-3.3 - # VARIANT_TAG_WITH_REF: v3.0.1-alpine-3.3-${GITHUB_REF} - VARIANT_BUILD_DIR: variants/v3.0.1-alpine-3.3 - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - - name: Clean-up - run: docker logout - if: always() \ No newline at end of file diff --git a/generate/definitions/FILES.ps1 b/generate/definitions/FILES.ps1 index a8ad32c..fc70558 100644 --- a/generate/definitions/FILES.ps1 +++ b/generate/definitions/FILES.ps1 @@ -1,7 +1,8 @@ # Files' definition $FILES = @( '.github/workflows/ci-master-pr.yml' - '.github/workflows/ci-release.yml' + # '.github/workflows/ci-release.yml' + '.github/release-drafter.yml' # '.gitlab-ci.yml' 'README.md' ) diff --git a/generate/templates/.github/release-drafter.yml.ps1 b/generate/templates/.github/release-drafter.yml.ps1 new file mode 100644 index 0000000..9c9c5ca --- /dev/null +++ b/generate/templates/.github/release-drafter.yml.ps1 @@ -0,0 +1,54 @@ +@' +# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. +name-template: '$RESOLVED_VERSION 🌈' +tag-template: '$RESOLVED_VERSION' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🖊️ Refactors' + labels: + - 'refactor' + - title: '👗 Style' + labels: + - 'style' + - title: '📝 Documentation' + labels: + - 'docs' + - 'documentation' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +version-resolver: + major: + labels: + # - 'major' + - 'breaking' + minor: + labels: + # - 'minor' + - 'feature' + - 'enhancement' + - 'refactor' + patch: + labels: + # - 'patch' + - 'fix' + - 'bugfix' + - 'bug' + - 'style' + - 'docs' + - 'documentation' + default: patch +sort-by: title +template: | + ## Changes + + $CHANGES +'@ diff --git a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 index 5b7ee06..d82cef7 100644 --- a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 +++ b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 @@ -5,18 +5,20 @@ on: push: branches: - master + - release # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. pull_request: branches: - master - jobs: '@ +$local:WORKFLOW_JOB_NAMES = $VARIANTS | % { "build-$( $_['tag'].Replace('.', '-') )" } $( $VARIANTS | % { @" + build-$( $_['tag'].Replace('.', '-') ): - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: VARIANT_TAG: $( $_['tag'] ) # VARIANT_TAG_WITH_REF: $( $_['tag'] )-`${GITHUB_REF} @@ -25,7 +27,9 @@ $( $VARIANTS | % { @' steps: - - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Display system info (linux) run: | set -e @@ -38,36 +42,234 @@ $( $VARIANTS | % { pwd docker info docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image + + # See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Prepare + id: prep env: DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} run: | set -e - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) + # Get 'namespace' and 'project-name' from 'namespace/project-name' + # CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 ) + # CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 ) # Get 'ref-name' from 'refs/heads/ref-name' REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - # Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' + # For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine' VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" + # Set step output(s) + # echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE" + # echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME" + # echo "::set-output name=REF::$REF" + # echo "::set-output name=SHA_SHORT::$SHA_SHORT" + # echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT" + + # For Generate-DockerImageVariants: Set step output(s) + echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR" + echo "::set-output name=VARIANT_TAG::$VARIANT_TAG" + echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF" + echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT" + + - name: Login to docker registry + run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin + env: + DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} + DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + + - name: Build (PRs) + id: docker_build_pr + # Run only on pull requests + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: false + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (master) + id: docker_build_master + # Run only on master + if: github.ref == 'refs/heads/master' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build and push (release) + id: docker_build_release + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + uses: docker/build-push-action@v2 + with: + context: ${{ steps.prep.outputs.CONTEXT }} + platforms: linux/amd64 + push: true + tags: | + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + +'@ + +if ( $_['tag_as_latest'] ) { +@' + ${{ github.repository }}:latest + +'@ +} +@' + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + - name: List docker images + run: docker images + - name: Clean-up run: docker logout if: always() '@ }) + +@" + + + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + converge-master-and-release-branches: + needs: [$( $local:WORKFLOW_JOB_NAMES -join ', ' )] + if: github.ref == 'refs/heads/release' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Merge release into master (fast-forward) + run: | + git checkout master + git merge release + git push origin master +"@ + +@' + + + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + resolve-release-tag: + runs-on: ubuntu-latest + outputs: + TAG: ${{ steps.resolve-release-tag.outputs.TAG }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Resolve release tag + id: resolve-release-tag + run: | + set +e + # E.g. 20210402 + TODAYS_DATE=$( date -u '+%Y%m%d' ) + # Is this the first tag for this date? + TODAYS_DATE_TAGS=$( git tag --list | grep "^$TODAYS_DATE" ) + TAG= + if [ -z "$TODAYS_DATE_TAGS" ]; then + # E.g. 20210402.0.0 + TAG="$TODAYS_DATE.0.0" # Send this to stdout + else + # E.g. if there are 20210402.0.0, 20210402.0.1, 20210402.0.2, this returns 2 + VERSION_MINOR_LATEST=$( echo "$TODAYS_DATE_TAGS" | cut -d '.' -f 3 | sort -nr | head -n1 ) + # Minor version + VERSION_MINOR=$( expr "$VERSION_MINOR_LATEST" + 1 ) + # E.g. 20210402.0.3 + TAG="$TODAYS_DATE.0.$VERSION_MINOR" # Send this to stdout + fi + echo "TODAYS_DATE: $TODAYS_DATE" + echo "TODAYS_DATE_TAGS: $TODAYS_DATE_TAGS" + echo "TAG: $TAG" + echo "::set-output name=TAG::$TAG" + - name: Print outputs + run: echo ${{ steps.resolve-release-tag.outputs.TAG }} +'@ + +@" + + + update-draft-release: + needs: [$( $local:WORKFLOW_JOB_NAMES -join ', ' ), resolve-release-tag] +"@ +@' + + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Print inputs + run: echo ${{ needs.resolve-release-tag.outputs.TAG }} + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: false + name: ${{ needs.resolve-release-tag.outputs.TAG }} + tag: ${{ needs.resolve-release-tag.outputs.TAG }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +'@ + +@" + + + publish-draft-release: + needs: [$( $local:WORKFLOW_JOB_NAMES -join ', ' ), converge-master-and-release-branches, resolve-release-tag] +"@ +@' + + # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release. + # if: startsWith(github.ref, 'refs/tags/') + if: github.ref == 'refs/heads/release' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: true + name: ${{ needs.resolve-release-tag.outputs.TAG }} + tag: ${{ needs.resolve-release-tag.outputs.TAG }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +'@ diff --git a/generate/templates/.github/workflows/ci-release.yml.ps1 b/generate/templates/.github/workflows/ci-release.yml.ps1 deleted file mode 100644 index 87f701c..0000000 --- a/generate/templates/.github/workflows/ci-release.yml.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -@' -name: ci-release - -on: - push: - branches: - - release - -jobs: -'@ - -$( $VARIANTS | % { -@" - - build-$( $_['tag'].Replace('.', '-') ): - runs-on: ubuntu-18.04 - env: - VARIANT_TAG: $( $_['tag'] ) - # VARIANT_TAG_WITH_REF: $( $_['tag'] )-`${GITHUB_REF} - VARIANT_BUILD_DIR: $( $_['build_dir_rel'] ) -"@ -@' - - steps: - - uses: actions/checkout@v1 - - name: Display system info (linux) - run: | - set -e - hostname - whoami - cat /etc/*release - lscpu - free - df -h - pwd - docker info - docker version - - name: Login to docker registry - run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} - - name: Build and push image - env: - DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - run: | - set -e - - # Get 'project-name' from 'namespace/project-name' - CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev ) - - # Get 'ref-name' from 'refs/heads/ref-name' - REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev ) - SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 ) - - # Generate the final tags. E.g. 'release-v1.0.0-alpine' and 'release-b29758a-v1.0.0-alpine' - VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}" - VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}" - - docker build \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \ - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \ - -'@ -if ( $_['tag_as_latest'] ) { -@' - -t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:latest" \ - -'@ -} -@' - "${VARIANT_BUILD_DIR}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" - -'@ -if ( $_['tag_as_latest'] ) { -@' - docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:latest" - -'@ -} -@' - - name: Clean-up - run: docker logout - if: always() -'@ -}) From bb481cbed3212d874ec1e37df75b5f3f1096d27e Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 12 Sep 2021 18:46:55 +0000 Subject: [PATCH 3/6] Refactor (generate): Remove Dockerfile.header.ps1 and Dockerfile.footer.ps1 and only use Dockerfile.ps1 --- generate/definitions/VARIANTS.ps1 | 4 ++-- generate/templates/Dockerfile.footer.ps1 | 2 -- generate/templates/Dockerfile.header.ps1 | 2 -- generate/templates/Dockerfile.ps1 | 1 + variants/v3.0.1-alpine-3.3/Dockerfile | 3 --- variants/v3.0.1-alpine-3.4/Dockerfile | 3 --- variants/v3.0.1-alpine-3.5/Dockerfile | 3 --- variants/v3.0.1-alpine-3.6/Dockerfile | 3 --- variants/v3.0.3-alpine-3.7/Dockerfile | 3 --- variants/v3.0.4-alpine-3.8/Dockerfile | 3 --- variants/v3.0.5-alpine-3.9/Dockerfile | 3 --- variants/v3.0.6-alpine-3.10/Dockerfile | 3 --- variants/v3.0.6-alpine-3.11/Dockerfile | 3 --- variants/v3.0.7-alpine-3.12/Dockerfile | 3 --- variants/v3.0.8-alpine-3.13/Dockerfile | 3 --- 15 files changed, 3 insertions(+), 39 deletions(-) delete mode 100755 generate/templates/Dockerfile.footer.ps1 delete mode 100755 generate/templates/Dockerfile.header.ps1 diff --git a/generate/definitions/VARIANTS.ps1 b/generate/definitions/VARIANTS.ps1 index b324ca7..041f95a 100644 --- a/generate/definitions/VARIANTS.ps1 +++ b/generate/definitions/VARIANTS.ps1 @@ -137,8 +137,8 @@ $VARIANTS_SHARED = @{ templates = @{ 'Dockerfile' = @{ common = $true - includeHeader = $true - includeFooter = $true + includeHeader = $false + includeFooter = $false passes = @( @{ variables = @{} diff --git a/generate/templates/Dockerfile.footer.ps1 b/generate/templates/Dockerfile.footer.ps1 deleted file mode 100755 index d008103..0000000 --- a/generate/templates/Dockerfile.footer.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -@" -"@ diff --git a/generate/templates/Dockerfile.header.ps1 b/generate/templates/Dockerfile.header.ps1 deleted file mode 100755 index d008103..0000000 --- a/generate/templates/Dockerfile.header.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -@" -"@ diff --git a/generate/templates/Dockerfile.ps1 b/generate/templates/Dockerfile.ps1 index 621d5fe..73fdc2c 100644 --- a/generate/templates/Dockerfile.ps1 +++ b/generate/templates/Dockerfile.ps1 @@ -20,4 +20,5 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] + "@ diff --git a/variants/v3.0.1-alpine-3.3/Dockerfile b/variants/v3.0.1-alpine-3.3/Dockerfile index 7eb3f17..cdb63b1 100644 --- a/variants/v3.0.1-alpine-3.3/Dockerfile +++ b/variants/v3.0.1-alpine-3.3/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.3 RUN apk add --no-cache easy-rsa=3.0.1-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.1-alpine-3.4/Dockerfile b/variants/v3.0.1-alpine-3.4/Dockerfile index 8423a21..8d5e2c3 100644 --- a/variants/v3.0.1-alpine-3.4/Dockerfile +++ b/variants/v3.0.1-alpine-3.4/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.4 RUN apk add --no-cache easy-rsa=3.0.1-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.1-alpine-3.5/Dockerfile b/variants/v3.0.1-alpine-3.5/Dockerfile index 57eaf86..ac43b30 100644 --- a/variants/v3.0.1-alpine-3.5/Dockerfile +++ b/variants/v3.0.1-alpine-3.5/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.5 RUN apk add --no-cache easy-rsa=3.0.1-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.1-alpine-3.6/Dockerfile b/variants/v3.0.1-alpine-3.6/Dockerfile index 3a2b631..8c95b09 100644 --- a/variants/v3.0.1-alpine-3.6/Dockerfile +++ b/variants/v3.0.1-alpine-3.6/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.6 RUN apk add --no-cache easy-rsa=3.0.1-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.3-alpine-3.7/Dockerfile b/variants/v3.0.3-alpine-3.7/Dockerfile index b4e113d..3e007c4 100644 --- a/variants/v3.0.3-alpine-3.7/Dockerfile +++ b/variants/v3.0.3-alpine-3.7/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.7 RUN apk add --no-cache easy-rsa=3.0.3-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.4-alpine-3.8/Dockerfile b/variants/v3.0.4-alpine-3.8/Dockerfile index df23fad..067a764 100644 --- a/variants/v3.0.4-alpine-3.8/Dockerfile +++ b/variants/v3.0.4-alpine-3.8/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.8 RUN apk add --no-cache easy-rsa=3.0.4-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.5-alpine-3.9/Dockerfile b/variants/v3.0.5-alpine-3.9/Dockerfile index e798f91..9b7e14b 100644 --- a/variants/v3.0.5-alpine-3.9/Dockerfile +++ b/variants/v3.0.5-alpine-3.9/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.9 RUN apk add --no-cache easy-rsa=3.0.5-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.6-alpine-3.10/Dockerfile b/variants/v3.0.6-alpine-3.10/Dockerfile index 1de126e..942ba14 100644 --- a/variants/v3.0.6-alpine-3.10/Dockerfile +++ b/variants/v3.0.6-alpine-3.10/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.10 RUN apk add --no-cache easy-rsa=3.0.6-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.6-alpine-3.11/Dockerfile b/variants/v3.0.6-alpine-3.11/Dockerfile index b52ab49..7c04615 100644 --- a/variants/v3.0.6-alpine-3.11/Dockerfile +++ b/variants/v3.0.6-alpine-3.11/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.11 RUN apk add --no-cache easy-rsa=3.0.6-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.7-alpine-3.12/Dockerfile b/variants/v3.0.7-alpine-3.12/Dockerfile index d4926f0..125aabd 100644 --- a/variants/v3.0.7-alpine-3.12/Dockerfile +++ b/variants/v3.0.7-alpine-3.12/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.12 RUN apk add --no-cache easy-rsa=3.0.7-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - diff --git a/variants/v3.0.8-alpine-3.13/Dockerfile b/variants/v3.0.8-alpine-3.13/Dockerfile index ea87015..6c9690d 100644 --- a/variants/v3.0.8-alpine-3.13/Dockerfile +++ b/variants/v3.0.8-alpine-3.13/Dockerfile @@ -1,5 +1,3 @@ - - FROM alpine:3.13 RUN apk add --no-cache easy-rsa=3.0.8-r0 iptables @@ -21,4 +19,3 @@ RUN echo "Looking for openssl.cnf" \ && find / -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] - From 374e54380f456869dd27dcd8035f232a7832e480 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 12 Sep 2021 18:52:19 +0000 Subject: [PATCH 4/6] Docs (readme): Replace tag badge with release badge --- README.md | 2 +- generate/templates/README.md.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 00d72c7..0a91638 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # docker-easyrsa [![github-actions](https://github.com/theohbrothers/docker-easyrsa/workflows/ci-master-pr/badge.svg)](https://github.com/theohbrothers/docker-easyrsa/actions) -[![github-tag](https://img.shields.io/github/tag/theohbrothers/docker-easyrsa)](https://github.com/theohbrothers/docker-easyrsa/releases/) +[![github-release](https://img.shields.io/github/v/release/theohbrothers/docker-easyrsa?style=flat-square)](https://github.com/theohbrothers/docker-easyrsa/releases/) [![docker-image-size](https://img.shields.io/docker/image-size/theohbrothers/docker-easyrsa/latest)](https://hub.docker.com/r/theohbrothers/docker-easyrsa) Dockerized [`easy-rsa`](https://github.com/OpenVPN/easy-rsa). diff --git a/generate/templates/README.md.ps1 b/generate/templates/README.md.ps1 index 8ed1844..efbbc26 100644 --- a/generate/templates/README.md.ps1 +++ b/generate/templates/README.md.ps1 @@ -2,7 +2,7 @@ # docker-easyrsa [![github-actions](https://github.com/theohbrothers/docker-easyrsa/workflows/ci-master-pr/badge.svg)](https://github.com/theohbrothers/docker-easyrsa/actions) -[![github-tag](https://img.shields.io/github/tag/theohbrothers/docker-easyrsa)](https://github.com/theohbrothers/docker-easyrsa/releases/) +[![github-release](https://img.shields.io/github/v/release/theohbrothers/docker-easyrsa?style=flat-square)](https://github.com/theohbrothers/docker-easyrsa/releases/) [![docker-image-size](https://img.shields.io/docker/image-size/theohbrothers/docker-easyrsa/latest)](https://hub.docker.com/r/theohbrothers/docker-easyrsa) Dockerized [``easy-rsa``](https://github.com/OpenVPN/easy-rsa). From 082f8fa92d934406e5244a2237a6f02a13adccbb Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 12 Sep 2021 19:04:33 +0000 Subject: [PATCH 5/6] Refactor (definitions): Remove sending definition objects down the pipeline --- generate/definitions/FILES.ps1 | 3 --- generate/definitions/VARIANTS.ps1 | 3 --- 2 files changed, 6 deletions(-) diff --git a/generate/definitions/FILES.ps1 b/generate/definitions/FILES.ps1 index fc70558..56671c0 100644 --- a/generate/definitions/FILES.ps1 +++ b/generate/definitions/FILES.ps1 @@ -6,6 +6,3 @@ $FILES = @( # '.gitlab-ci.yml' 'README.md' ) - -# Send definitions down the pipeline -$FILES diff --git a/generate/definitions/VARIANTS.ps1 b/generate/definitions/VARIANTS.ps1 index 041f95a..3fededc 100644 --- a/generate/definitions/VARIANTS.ps1 +++ b/generate/definitions/VARIANTS.ps1 @@ -168,6 +168,3 @@ $VARIANTS_SHARED = @{ } } } - -# Send definitions down the pipeline -$VARIANTS From d3fb1e718bacdf9fd3e05579628868995a6093e9 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Sun, 12 Sep 2021 20:06:09 +0000 Subject: [PATCH 6/6] Enhancement: Build multi arch docker image Note: There's only `linux/amd64` image for`alpine:3.3` to `alpine:3.5`, see https://hub.docker.com/_/alpine?tab=tags&page=1&ordering=last_updated&name=3.5 --- .github/workflows/ci-master-pr.yml | 48 +++++++++---------- .../.github/workflows/ci-master-pr.yml.ps1 | 35 +++++++------- generate/templates/Dockerfile.ps1 | 6 +-- variants/v3.0.1-alpine-3.3/Dockerfile | 6 +-- variants/v3.0.1-alpine-3.4/Dockerfile | 6 +-- variants/v3.0.1-alpine-3.5/Dockerfile | 6 +-- variants/v3.0.1-alpine-3.6/Dockerfile | 6 +-- variants/v3.0.3-alpine-3.7/Dockerfile | 6 +-- variants/v3.0.4-alpine-3.8/Dockerfile | 6 +-- variants/v3.0.5-alpine-3.9/Dockerfile | 6 +-- variants/v3.0.6-alpine-3.10/Dockerfile | 6 +-- variants/v3.0.6-alpine-3.11/Dockerfile | 6 +-- variants/v3.0.7-alpine-3.12/Dockerfile | 6 +-- variants/v3.0.8-alpine-3.13/Dockerfile | 6 +-- 14 files changed, 79 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index 6ce7eef..7c865e8 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -94,7 +94,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -109,7 +109,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -124,7 +124,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -225,7 +225,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -240,7 +240,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -255,7 +255,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -355,7 +355,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -370,7 +370,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -385,7 +385,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -485,7 +485,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -500,7 +500,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -515,7 +515,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -615,7 +615,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -630,7 +630,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -645,7 +645,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -745,7 +745,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -760,7 +760,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -775,7 +775,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -875,7 +875,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -890,7 +890,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -905,7 +905,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} @@ -1005,7 +1005,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: false tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -1020,7 +1020,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} @@ -1035,7 +1035,7 @@ jobs: uses: docker/build-push-action@v2 with: context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x push: true tags: | ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} diff --git a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 index d82cef7..1ac0a22 100644 --- a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 +++ b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 @@ -13,7 +13,7 @@ jobs: '@ $local:WORKFLOW_JOB_NAMES = $VARIANTS | % { "build-$( $_['tag'].Replace('.', '-') )" } -$( $VARIANTS | % { +$VARIANTS | % { @" @@ -97,18 +97,21 @@ $( $VARIANTS | % { DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }} DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + +'@ +@" - name: Build (PRs) id: docker_build_pr # Run only on pull requests if: github.event_name == 'pull_request' uses: docker/build-push-action@v2 with: - context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + context: `${{ steps.prep.outputs.CONTEXT }} + platforms: $( if ($_['_metadata']['distro'] -eq 'alpine' -and $_['_metadata']['distro_version'] -in @( '3.3', '3.4', '3.5' ) ) { 'linux/amd64' } else { 'linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x' } ) push: false tags: | - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache @@ -118,12 +121,12 @@ $( $VARIANTS | % { if: github.ref == 'refs/heads/master' uses: docker/build-push-action@v2 with: - context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + context: `${{ steps.prep.outputs.CONTEXT }} + platforms: $( if ($_['_metadata']['distro'] -eq 'alpine' -and $_['_metadata']['distro_version'] -in @( '3.3', '3.4', '3.5' ) ) { 'linux/amd64' } else { 'linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x' } ) push: true tags: | - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-to: type=local,dest=/tmp/.buildx-cache - name: Build and push (release) @@ -133,15 +136,15 @@ $( $VARIANTS | % { if: github.ref == 'refs/heads/release' uses: docker/build-push-action@v2 with: - context: ${{ steps.prep.outputs.CONTEXT }} - platforms: linux/amd64 + context: `${{ steps.prep.outputs.CONTEXT }} + platforms: $( if ($_['_metadata']['distro'] -eq 'alpine' -and $_['_metadata']['distro_version'] -in @( '3.3', '3.4', '3.5' ) ) { 'linux/amd64' } else { 'linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x' } ) push: true tags: | - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }} - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} - ${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }} + `${{ github.repository }}:`${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} -'@ +"@ if ( $_['tag_as_latest'] ) { @' @@ -160,7 +163,7 @@ if ( $_['tag_as_latest'] ) { run: docker logout if: always() '@ -}) +} @" diff --git a/generate/templates/Dockerfile.ps1 b/generate/templates/Dockerfile.ps1 index 73fdc2c..7361512 100644 --- a/generate/templates/Dockerfile.ps1 +++ b/generate/templates/Dockerfile.ps1 @@ -8,16 +8,16 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.1-alpine-3.3/Dockerfile b/variants/v3.0.1-alpine-3.3/Dockerfile index cdb63b1..bf2c7d6 100644 --- a/variants/v3.0.1-alpine-3.3/Dockerfile +++ b/variants/v3.0.1-alpine-3.3/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.1-alpine-3.4/Dockerfile b/variants/v3.0.1-alpine-3.4/Dockerfile index 8d5e2c3..459e6f8 100644 --- a/variants/v3.0.1-alpine-3.4/Dockerfile +++ b/variants/v3.0.1-alpine-3.4/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.1-alpine-3.5/Dockerfile b/variants/v3.0.1-alpine-3.5/Dockerfile index ac43b30..5aca9ba 100644 --- a/variants/v3.0.1-alpine-3.5/Dockerfile +++ b/variants/v3.0.1-alpine-3.5/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.1-alpine-3.6/Dockerfile b/variants/v3.0.1-alpine-3.6/Dockerfile index 8c95b09..481c890 100644 --- a/variants/v3.0.1-alpine-3.6/Dockerfile +++ b/variants/v3.0.1-alpine-3.6/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.3-alpine-3.7/Dockerfile b/variants/v3.0.3-alpine-3.7/Dockerfile index 3e007c4..b144121 100644 --- a/variants/v3.0.3-alpine-3.7/Dockerfile +++ b/variants/v3.0.3-alpine-3.7/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.4-alpine-3.8/Dockerfile b/variants/v3.0.4-alpine-3.8/Dockerfile index 067a764..2ff5dbe 100644 --- a/variants/v3.0.4-alpine-3.8/Dockerfile +++ b/variants/v3.0.4-alpine-3.8/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.5-alpine-3.9/Dockerfile b/variants/v3.0.5-alpine-3.9/Dockerfile index 9b7e14b..73d41af 100644 --- a/variants/v3.0.5-alpine-3.9/Dockerfile +++ b/variants/v3.0.5-alpine-3.9/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.6-alpine-3.10/Dockerfile b/variants/v3.0.6-alpine-3.10/Dockerfile index 942ba14..ccbc75b 100644 --- a/variants/v3.0.6-alpine-3.10/Dockerfile +++ b/variants/v3.0.6-alpine-3.10/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.6-alpine-3.11/Dockerfile b/variants/v3.0.6-alpine-3.11/Dockerfile index 7c04615..a4e3c1d 100644 --- a/variants/v3.0.6-alpine-3.11/Dockerfile +++ b/variants/v3.0.6-alpine-3.11/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.7-alpine-3.12/Dockerfile b/variants/v3.0.7-alpine-3.12/Dockerfile index 125aabd..256113d 100644 --- a/variants/v3.0.7-alpine-3.12/Dockerfile +++ b/variants/v3.0.7-alpine-3.12/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/variants/v3.0.8-alpine-3.13/Dockerfile b/variants/v3.0.8-alpine-3.13/Dockerfile index 6c9690d..c812c48 100644 --- a/variants/v3.0.8-alpine-3.13/Dockerfile +++ b/variants/v3.0.8-alpine-3.13/Dockerfile @@ -7,15 +7,15 @@ RUN chmod +x /docker-entrypoint.sh # alpine easyrsa top-level directory. Use command find / -name 'easyrsa' RUN echo "Looking for easyrsa binary" \ - && find / -name 'easyrsa' + && ls '/usr/share/easy-rsa/easyrsa' ENV EASYRSA=/usr/share/easy-rsa WORKDIR /usr/share/easy-rsa # alpine openssl.cnf location. Use command find / -name 'openssl*.cnf' # < v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.0/easyrsa3/easyrsa#L1032-L1033 -# >= v3.0.4: https://github.com/OpenVPN/easy-rsa/blob/v3.0.4/easyrsa3/easyrsa#L1091-L1092 +# >= v3.0.4: RUN echo "Looking for openssl.cnf" \ - && find / -name 'openssl*.cnf' + && find /etc /usr -name 'openssl*.cnf' ENTRYPOINT ["/docker-entrypoint.sh"]