From 7c277af234cda3492f74a953841f7493949c35c9 Mon Sep 17 00:00:00 2001 From: sotojn Date: Mon, 15 Jul 2024 11:41:58 -0700 Subject: [PATCH 01/15] update actions versions --- .github/workflows/build.yml | 10 +++++----- .github/workflows/release.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ff96dc..454e6c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,21 +17,21 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: platforms: linux/arm64,linux/amd64 - name: Build - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . platforms: linux/arm64,linux/amd64 @@ -42,7 +42,7 @@ jobs: tags: terascope/node-base:${{ matrix.version }}-test - name: Build Core - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . platforms: linux/arm64,linux/amd64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4effdcc..e7d5bab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,21 +18,21 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: platforms: linux/arm64,linux/amd64 - name: Build - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . platforms: linux/arm64,linux/amd64 @@ -43,7 +43,7 @@ jobs: tags: terascope/node-base:${{ matrix.version }} - name: Build Core - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . platforms: linux/arm64,linux/amd64 From ff9aae4224e50b1b8a97329230f5a641a9556f61 Mon Sep 17 00:00:00 2001 From: sotojn Date: Mon, 15 Jul 2024 13:26:03 -0700 Subject: [PATCH 02/15] add major and minor version to matrix --- .github/workflows/build.yml | 4 +++- .github/workflows/release.yml | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 454e6c5..f6e8d6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,9 @@ jobs: strategy: matrix: # NOTE: These versions must be kept in sync with the release.yml - version: ["18.19.1", "20.11.1", "22.2.0"] + version: ["18", "18.19", "18.19.1", + "20", "20.11", "20.11.1", + "22", "22.2", "22.2.0"] runs-on: ubuntu-latest steps: - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7d5bab..9dc1cc4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,10 @@ jobs: strategy: matrix: # NOTE: These versions must be kept in sync with the build.yml - version: ["18.19.1", "20.11.1", "22.2.0"] + version: ["18", "18.19", "18.19.1", + "20", "20.11", "20.11.1", + "22", "22.2", "22.2.0"] + runs-on: ubuntu-latest steps: - From d3f5d04b49c08161094c200a7666bfed1dd3b234 Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 10:27:57 -0700 Subject: [PATCH 03/15] refactor node version workflow --- .github/workflows/build.yml | 56 ++++++++++++++++++++++++++++++----- .github/workflows/release.yml | 31 +++++++++++++++---- extract-semver.js | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 extract-semver.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6e8d6e..955c32b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,25 +7,35 @@ on: - '*' - '!master' +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository_owner }}/node-base + jobs: build_matrix: strategy: matrix: # NOTE: These versions must be kept in sync with the release.yml - version: ["18", "18.19", "18.19.1", - "20", "20.11", "20.11.1", - "22", "22.2", "22.2.0"] + version: ["22"] runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: - name: Checkout uses: actions/checkout@v4 - - name: Login to Docker Hub + name: Log in to the Container registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -41,7 +51,34 @@ jobs: pull: true push: true file: ./Dockerfile - tags: terascope/node-base:${{ matrix.version }}-test + tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-test" + cache-to: + - + name: Grab Current Version + id: current_version + run: echo "::set-output name=current_node_version::$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" + # run: echo "CURRENT_NODE_VERSION=$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" >> $GITHUB_ENV + - + name: Grab Minor Version + id: minor_version + # run: echo "MINOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} minor)" >> $GITHUB_ENV + run: | + echo "::set-output name=minor::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} minor)" + + - + name: Grab Patch Version + id: patch_version + # run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV + run: | + echo "::set-output name=patch::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} patch)" + + - + name: Retag, and push image + run: | + docker tag ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test + docker push ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test + docker tag ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test + docker push ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test - name: Build Core uses: docker/build-push-action@v6 @@ -52,4 +89,7 @@ jobs: pull: true push: true file: ./Dockerfile.core - tags: terascope/node-base:${{ matrix.version }}-core-test + tags: | + "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core-test" + "${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-core-test" + "${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-core-test" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9dc1cc4..f959e86 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,10 @@ on: - cron: '30 5 * * 0' # Sunday's at 0530 workflow_dispatch: +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository_owner }}/node-base + jobs: build_and_release_matrix: strategy: @@ -18,16 +22,24 @@ jobs: "22", "22.2", "22.2.0"] runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: - name: Checkout uses: actions/checkout@v4 - - name: Login to Docker Hub + name: Log in to the Container registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -43,7 +55,7 @@ jobs: pull: true push: true file: ./Dockerfile - tags: terascope/node-base:${{ matrix.version }} + tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}" - name: Build Core uses: docker/build-push-action@v6 @@ -54,4 +66,13 @@ jobs: pull: true push: true file: ./Dockerfile.core - tags: terascope/node-base:${{ matrix.version }}-core + tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core" + + # Look into this more: + # https://docs.github.com/en/actions/publishing-packages/publishing-docker-images + # - name: Generate artifact attestation + # uses: actions/attest-build-provenance@v1 + # with: + # subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + # subject-digest: ${{ steps.build_and_release_matrix.outputs.digest }} + # push-to-registry: true diff --git a/extract-semver.js b/extract-semver.js new file mode 100644 index 0000000..c600e5c --- /dev/null +++ b/extract-semver.js @@ -0,0 +1,52 @@ +'use strict' + +let rawSemver = process.argv[2]; +const type = process.argv[3]; + +function isValidSemver(version) { + // Remove leading 'v' if present + if (version.startsWith('v')) { + version = version.slice(1); + } + const semverRegex = /^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/; + return semverRegex.test(version); +} + +if (rawSemver === undefined || rawSemver === null) { + throw new Error(`Input of first arg is undefined! Input a valid semver.`); +} else if (typeof rawSemver !== 'string') { + throw new Error(`Input must be a string! Got ${typeof rawSemver}`); +} else if (!isValidSemver(rawSemver)) { + throw new Error(`Input ${rawSemver} is not a valid semver format`); +} + +if ( + type === undefined || + type === null || + (type !== 'minor' && type !== 'patch') +) { + throw new Error('You must define a type of either "minor" or "patch" as the second argument.'); +} + +function getSemverPart(semver, part) { + // Remove leading 'v' if present + if (semver.startsWith('v')) { + semver = semver.slice(1); + } + const semverRegex = /^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/; + const match = semver.match(semverRegex); + if (!match) { + throw new Error('Invalid semver format'); + } + switch (part) { + case 'minor': + return parseInt(match[2], 10); + case 'patch': + return parseInt(match[3], 10); + default: + throw new Error('Invalid part specified. Use "minor" or "patch".'); + } +} + + +process.stdout.write(getSemverPart(rawSemver, type).toString()); \ No newline at end of file From cbca867cae0693fbb98a949e6acb22efe6baa2fc Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 11:09:04 -0700 Subject: [PATCH 04/15] fix crash --- .github/workflows/build.yml | 12 ++---------- .github/workflows/release.yml | 15 ++------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 955c32b..b767e83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ on: - '!master' env: - REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository_owner }}/node-base jobs: @@ -19,12 +18,6 @@ jobs: version: ["22"] runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write - steps: - name: Checkout @@ -33,9 +26,8 @@ jobs: name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f959e86..6c914ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,10 +8,6 @@ on: - cron: '30 5 * * 0' # Sunday's at 0530 workflow_dispatch: -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository_owner }}/node-base - jobs: build_and_release_matrix: strategy: @@ -23,12 +19,6 @@ jobs: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write - steps: - name: Checkout @@ -37,9 +27,8 @@ jobs: name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From 5686bfebe6b4f6eec9677582603d2d4d092027b7 Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 15:00:56 -0700 Subject: [PATCH 05/15] fix manifest for tagging --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b767e83..557f382 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,10 +67,10 @@ jobs: - name: Retag, and push image run: | - docker tag ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test - docker push ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test - docker tag ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test - docker push ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test - name: Build Core uses: docker/build-push-action@v6 From 8086fb1e8c23f9f93d4b4c1dc5cfb267cec478a2 Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 16:06:22 -0700 Subject: [PATCH 06/15] fix deprication in yaml --- .github/workflows/build.yml | 66 +++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 557f382..cf9e7f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: # NOTE: These versions must be kept in sync with the release.yml - version: ["22"] + version: ["18", "20", "22"] runs-on: ubuntu-latest steps: @@ -43,45 +43,53 @@ jobs: pull: true push: true file: ./Dockerfile - tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-test" - cache-to: + tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-test" - name: Grab Current Version id: current_version - run: echo "::set-output name=current_node_version::$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" - # run: echo "CURRENT_NODE_VERSION=$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" >> $GITHUB_ENV + # run: echo "::set-output name=current_node_version::$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" + run: echo "CURRENT_NODE_VERSION=$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" >> $GITHUB_ENV - name: Grab Minor Version id: minor_version - # run: echo "MINOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} minor)" >> $GITHUB_ENV - run: | - echo "::set-output name=minor::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} minor)" + run: echo "MINOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} minor)" >> $GITHUB_ENV + # run: | + # echo "::set-output name=minor::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} minor)" - name: Grab Patch Version id: patch_version - # run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV - run: | - echo "::set-output name=patch::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} patch)" + run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV + # run: | + # echo "::set-output name=patch::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} patch)" + # - + # name: Retag, and push image + # run: | + # docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + # docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test + # docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + # docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test - name: Retag, and push image run: | - docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test - docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test - docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test - docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test - - - name: Build Core - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64,linux/amd64 - build-args: "NODE_VERSION=${{ matrix.version }}" - pull: true - push: true - file: ./Dockerfile.core - tags: | - "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core-test" - "${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-core-test" - "${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-core-test" + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }}-test + +# I don't think we use the core images and we should consider removing this and the Dockerfile.core file. + # - + # name: Build Core + # uses: docker/build-push-action@v6 + # with: + # context: . + # platforms: linux/arm64,linux/amd64 + # build-args: "NODE_VERSION=${{ matrix.version }}" + # pull: true + # push: true + # file: ./Dockerfile.core + # tags: | + # "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core-test" + # "${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-core-test" + # "${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-core-test" From bb43c24318db55e664d8df70d2a660aab5885e8d Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 16:38:08 -0700 Subject: [PATCH 07/15] remove comments --- .github/workflows/build.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf9e7f4..2c738c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,29 +47,15 @@ jobs: - name: Grab Current Version id: current_version - # run: echo "::set-output name=current_node_version::$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" run: echo "CURRENT_NODE_VERSION=$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test node -v)" >> $GITHUB_ENV - name: Grab Minor Version id: minor_version run: echo "MINOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} minor)" >> $GITHUB_ENV - # run: | - # echo "::set-output name=minor::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} minor)" - - name: Grab Patch Version id: patch_version run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV - # run: | - # echo "::set-output name=patch::$(node extract-semver.js ${{ steps.current_version.outputs.current_node_version }} patch)" - - # - - # name: Retag, and push image - # run: | - # docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test - # docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}-test - # docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test - # docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ steps.minor_version.outputs.minor }}.${{ steps.patch_version.outputs.patch }}-test - name: Retag, and push image run: | From 66f3d518256144dc139e38a9bb9a80918d2c54a8 Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 16:38:45 -0700 Subject: [PATCH 08/15] update readme with tag chnages --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 16617df..7b2b6b5 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,20 @@ # Terascope Base Docker images -This project builds the Terascope base images [used by Teraslice](https://github.com/terascope/teraslice/blob/master/Dockerfile#L1). Below are the latest docker image tags. +This project builds the Terascope base images [used by Teraslice](https://github.com/terascope/teraslice/blob/master/Dockerfile#L1). Below are the latest docker image tags. Tags with only a major version use the latest minor and patch version. Tags with major/minor use the latest patch version. With the terafoundation connectors builtin: -- `terascope/node-base:22.2.0` -- `terascope/node-base:20.11.1` -- `terascope/node-base:18.19.1` +- `terascope/node-base:22` +- `terascope/node-base:20` +- `terascope/node-base:18` +- `terascope/node-base:22.*.*` +- `terascope/node-base:20.*.*` +- `terascope/node-base:18.*.*` Without: (this will save the image size by roughly 200MB) +**_DEPRECATED:_** Core images are no longer built and pushed to docker.hub. + - `terascope/node-base:22.2.0-core` - `terascope/node-base:20.11.1-core` - `terascope/node-base:18.19.1-core` From b797439aac5675c8cf2b78f3af41f95f7f6d6d2b Mon Sep 17 00:00:00 2001 From: sotojn Date: Tue, 16 Jul 2024 16:47:12 -0700 Subject: [PATCH 09/15] update release.yml with tag changes --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 50 ++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c738c6..dd08f2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: id: patch_version run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV - - name: Retag, and push image + name: Retag, and push minor/patch images run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c914ec..5dcd9e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,17 +8,16 @@ on: - cron: '30 5 * * 0' # Sunday's at 0530 workflow_dispatch: +env: + IMAGE_NAME: ${{ github.repository_owner }}/node-base + jobs: build_and_release_matrix: strategy: matrix: # NOTE: These versions must be kept in sync with the build.yml - version: ["18", "18.19", "18.19.1", - "20", "20.11", "20.11.1", - "22", "22.2", "22.2.0"] - + version: ["18", "20", "22"] runs-on: ubuntu-latest - steps: - name: Checkout @@ -46,16 +45,37 @@ jobs: file: ./Dockerfile tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}" - - name: Build Core - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64,linux/amd64 - build-args: "NODE_VERSION=${{ matrix.version }}" - pull: true - push: true - file: ./Dockerfile.core - tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core" + name: Grab Current Version + id: current_version + run: echo "CURRENT_NODE_VERSION=$(docker run ${{ env.IMAGE_NAME }}:${{ matrix.version }} node -v)" >> $GITHUB_ENV + - + name: Grab Minor Version + id: minor_version + run: echo "MINOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} minor)" >> $GITHUB_ENV + - + name: Grab Patch Version + id: patch_version + run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV + - + name: Retag, and push minor/patch images + run: | + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }} + +# I don't think we use the core images and we should consider removing this and the Dockerfile.core file. + # - + # name: Build Core + # uses: docker/build-push-action@v6 + # with: + # context: . + # platforms: linux/arm64,linux/amd64 + # build-args: "NODE_VERSION=${{ matrix.version }}" + # pull: true + # push: true + # file: ./Dockerfile.core + # tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}-core" # Look into this more: # https://docs.github.com/en/actions/publishing-packages/publishing-docker-images From 3e9e1cdeeabb449dc481eb4c9c604edc33cfe100 Mon Sep 17 00:00:00 2001 From: sotojn Date: Wed, 17 Jul 2024 09:34:11 -0700 Subject: [PATCH 10/15] add comment to yml files --- .github/workflows/build.yml | 3 +++ .github/workflows/release.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dd08f2a..05b2a8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,9 @@ jobs: strategy: matrix: # NOTE: These versions must be kept in sync with the release.yml + # In the case where a new node version introduces a breaking change, + # replace the major version of the matrix to a pinned version here. + # Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"] version: ["18", "20", "22"] runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5dcd9e2..700421f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,9 @@ jobs: strategy: matrix: # NOTE: These versions must be kept in sync with the build.yml + # In the case where a new node version introduces a breaking change, + # replace the major version of the matrix to a pinned version here. + # Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"] version: ["18", "20", "22"] runs-on: ubuntu-latest steps: From 47877ba02a2c1955d2d89a5149718f9576ec0f35 Mon Sep 17 00:00:00 2001 From: sotojn Date: Wed, 17 Jul 2024 12:31:59 -0700 Subject: [PATCH 11/15] add labels for node-version & kafka-connect version --- Dockerfile | 3 +++ Dockerfile.core | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 721c870..4546074 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,5 +67,8 @@ COPY wait-for-it.sh /usr/local/bin/wait-for-it ENV NODE_OPTIONS "--max-old-space-size=2048" +LABEL node_version="$NODE_VERSION" +LABEL kafka_connector_version="1.0.0" + # Use tini to handle sigterm and zombie processes ENTRYPOINT ["/sbin/tini", "--"] diff --git a/Dockerfile.core b/Dockerfile.core index 33d3fb5..6126987 100644 --- a/Dockerfile.core +++ b/Dockerfile.core @@ -37,5 +37,7 @@ COPY wait-for-it.sh /usr/local/bin/wait-for-it ENV NODE_OPTIONS "--max-old-space-size=2048" +LABEL node_version="$NODE_VERSION" + # Use tini to handle sigterm and zombie processes ENTRYPOINT ["/sbin/tini", "--"] From 8f431d29e27e17b1347a00c2991c62a02051e961 Mon Sep 17 00:00:00 2001 From: sotojn Date: Wed, 17 Jul 2024 17:59:51 -0700 Subject: [PATCH 12/15] fix specific node version matrix problem --- .github/workflows/build.yml | 25 ++++++++++++++++++++++++- .github/workflows/release.yml | 23 +++++++++++++++++++++++ extract-semver.js | 8 +++++--- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 05b2a8d..a60c2fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: # In the case where a new node version introduces a breaking change, # replace the major version of the matrix to a pinned version here. # Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"] - version: ["18", "20", "22"] + version: ["18.19.1", "20", "22"] runs-on: ubuntu-latest steps: @@ -59,13 +59,36 @@ jobs: name: Grab Patch Version id: patch_version run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV + - + name: Check for specific node version + id: check_specific_version + run: | + if [[ "${{ matrix.version }}" == *.* ]]; then + echo "SPECIFIC_VERSION=true" >> $GITHUB_ENV + else + echo "SPECIFIC_VERSION=false" >> $GITHUB_ENV + fi + - + name: Grab Major Version + if: ${{ env.SPECIFIC_VERSION}} == 'true' + id: major_version + run: echo "MAJOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} major)" >> $GITHUB_ENV - name: Retag, and push minor/patch images + if: ${{ env.SPECIFIC_VERSION}} == 'false' run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }}-test + - + name: Retag, and push major/minor images + if: ${{ env.SPECIFIC_VERSION}} == 'true' + run: | + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}-test + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }}-test # I don't think we use the core images and we should consider removing this and the Dockerfile.core file. # - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 700421f..023e0e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,13 +59,36 @@ jobs: name: Grab Patch Version id: patch_version run: echo "PATCH=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} patch)" >> $GITHUB_ENV + - + name: Check for specific node version + id: check_specific_version + run: | + if [[ "${{ matrix.version }}" == *.* ]]; then + echo "SPECIFIC_VERSION=true" >> $GITHUB_ENV + else + echo "SPECIFIC_VERSION=false" >> $GITHUB_ENV + fi + - + name: Grab Major Version + if: ${{ env.SPECIFIC_VERSION}} == 'true' + id: major_version + run: echo "MAJOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} major)" >> $GITHUB_ENV - name: Retag, and push minor/patch images + if: ${{ env.SPECIFIC_VERSION}} == 'false' run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }} + - + name: Retag, and push major/minor images + if: ${{ env.SPECIFIC_VERSION}} == 'true' + run: | + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }} + docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} + docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }} # I don't think we use the core images and we should consider removing this and the Dockerfile.core file. # - diff --git a/extract-semver.js b/extract-semver.js index c600e5c..849eb94 100644 --- a/extract-semver.js +++ b/extract-semver.js @@ -23,9 +23,9 @@ if (rawSemver === undefined || rawSemver === null) { if ( type === undefined || type === null || - (type !== 'minor' && type !== 'patch') + (type !== 'minor' && type !== 'patch' && type !== 'major') ) { - throw new Error('You must define a type of either "minor" or "patch" as the second argument.'); + throw new Error('You must define a type of either "major" "minor" or "patch" as the second argument.'); } function getSemverPart(semver, part) { @@ -39,12 +39,14 @@ function getSemverPart(semver, part) { throw new Error('Invalid semver format'); } switch (part) { + case 'major': + return parseInt(match[1], 10); case 'minor': return parseInt(match[2], 10); case 'patch': return parseInt(match[3], 10); default: - throw new Error('Invalid part specified. Use "minor" or "patch".'); + throw new Error('Invalid part specified. Use "major", "minor" or "patch".'); } } From 73a48c6852b90332081937bedbacd7247bfa384a Mon Sep 17 00:00:00 2001 From: sotojn Date: Thu, 18 Jul 2024 07:51:02 -0700 Subject: [PATCH 13/15] fix if statments in yaml --- .github/workflows/build.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a60c2fc..7d11eeb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,12 +70,12 @@ jobs: fi - name: Grab Major Version - if: ${{ env.SPECIFIC_VERSION}} == 'true' + if: ${{ env.SPECIFIC_VERSION == 'true' }} id: major_version run: echo "MAJOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} major)" >> $GITHUB_ENV - name: Retag, and push minor/patch images - if: ${{ env.SPECIFIC_VERSION}} == 'false' + if: ${{ env.SPECIFIC_VERSION == 'false' }} run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}-test @@ -83,7 +83,7 @@ jobs: docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }}-test - name: Retag, and push major/minor images - if: ${{ env.SPECIFIC_VERSION}} == 'true' + if: ${{ env.SPECIFIC_VERSION == 'true' }} run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}-test ${{ env.IMAGE_NAME }}:${{ matrix.version }}-test docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }}-test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 023e0e1..3d78243 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,12 +70,12 @@ jobs: fi - name: Grab Major Version - if: ${{ env.SPECIFIC_VERSION}} == 'true' + if: ${{ env.SPECIFIC_VERSION == 'true' }} id: major_version run: echo "MAJOR=$(node extract-semver.js ${{ env.CURRENT_NODE_VERSION }} major)" >> $GITHUB_ENV - name: Retag, and push minor/patch images - if: ${{ env.SPECIFIC_VERSION}} == 'false' + if: ${{ env.SPECIFIC_VERSION == 'false' }} run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }} @@ -83,7 +83,7 @@ jobs: docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ matrix.version }}.${{ env.MINOR }}.${{ env.PATCH }} - name: Retag, and push major/minor images - if: ${{ env.SPECIFIC_VERSION}} == 'true' + if: ${{ env.SPECIFIC_VERSION == 'true' }} run: | docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.MAJOR }} ${{ env.IMAGE_NAME }}:${{ matrix.version }} docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ env.MAJOR }} From 656a040d85ba6e67b41efd8738324b74571ff6ec Mon Sep 17 00:00:00 2001 From: Joseph Soto Date: Thu, 18 Jul 2024 13:16:33 -0700 Subject: [PATCH 14/15] Update .github/workflows/build.yml Co-authored-by: Austin Godber --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d11eeb..6c0e455 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: # In the case where a new node version introduces a breaking change, # replace the major version of the matrix to a pinned version here. # Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"] - version: ["18.19.1", "20", "22"] + version: ["18", "20", "22"] runs-on: ubuntu-latest steps: From d34bc1809c83b6c42f34a6fd0978f96d868bb41e Mon Sep 17 00:00:00 2001 From: sotojn Date: Thu, 18 Jul 2024 13:35:27 -0700 Subject: [PATCH 15/15] pin node 22.4.1 --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c0e455..39c93ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: # In the case where a new node version introduces a breaking change, # replace the major version of the matrix to a pinned version here. # Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"] - version: ["18", "20", "22"] + version: ["18", "20", "22.4.1"] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d78243..25955ba 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: # In the case where a new node version introduces a breaking change, # replace the major version of the matrix to a pinned version here. # Ex: ["18", "20", "22"] ---> ["18.19.1", "20", "22"] - version: ["18", "20", "22"] + version: ["18", "20", "22.4.1"] runs-on: ubuntu-latest steps: -