Skip to content

Commit 983f3bc

Browse files
committed
feat(typescript-node): updates release/nightly workflow
1 parent 5393b24 commit 983f3bc

File tree

3 files changed

+111
-27
lines changed

3 files changed

+111
-27
lines changed

.github/workflows/typescript-node-nightly.yml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,67 @@ jobs:
1111
build-and-push:
1212
runs-on: ubuntu-latest
1313
environment: STAGING
14+
permissions:
15+
contents: read
16+
packages: write
1417
steps:
15-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
1619

1720
- name: Set up QEMU
18-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # 3.6.0
21+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # 3.7.0
1922

2023
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
24+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # 3.12.0
2225

2326
- name: Login to Docker Hub
24-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
27+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # 3.6.0
2528
with:
2629
username: ${{ vars.DOCKERHUB_USERNAME }}
2730
password: ${{ secrets.DOCKERHUB_TOKEN }}
2831

2932
- name: Login to GHCR
30-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
33+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # 3.6.0
3134
with:
3235
registry: ghcr.io
3336
username: ${{ github.repository_owner }}
34-
password: ${{ secrets.GH_TOKEN }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
3538

36-
- name: Generate build tag
39+
- id: tag_builder
40+
name: Generate build tags
3741
run: |
3842
TIMESTAMP=$(date +'%Y%m%d')
3943
SHA=$(git rev-parse --short HEAD)
40-
echo "BUILD_TAG=nightly-${TIMESTAMP}-${SHA}" >> $GITHUB_ENV
44+
echo "build_tag=nightly-${TIMESTAMP}-${SHA}" >> $GITHUB_OUTPUT
45+
46+
# expose a separate tag for testing purposes
47+
echo "test_tag=nightly-test-${TIMESTAMP}-${SHA}" >> $GITHUB_OUTPUT
48+
49+
- name: Build image for testing
50+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
51+
with:
52+
context: source/typescript-node
53+
platforms: linux/amd64,linux/arm64
54+
push: false
55+
load: true
56+
tags: |
57+
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ steps.tag_builder.outputs.test_tag }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
61+
- name: Run test
62+
run: |
63+
TEST_IMAGE="${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ steps.tag_builder.outputs.test_tag }}"
64+
echo "Running smoke test against $TEST_IMAGE"
65+
docker run --rm "$TEST_IMAGE" node -v
4166
4267
- name: Build & Push image to registries
43-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
68+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
4469
with:
4570
context: source/typescript-node
4671
platforms: linux/amd64,linux/arm64
4772
push: true
4873
tags: |
49-
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ env.BUILD_TAG }}
50-
ghcr.io/${{ github.repository_owner }}/typescript-node:${{ env.BUILD_TAG }}
74+
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ steps.tag_builder.outputs.build_tag }}
75+
ghcr.io/${{ github.repository_owner }}/typescript-node:${{ steps.tag_builder.outputs.build_tag }}
5176
cache-from: type=gha
5277
cache-to: type=gha,mode=max

.github/workflows/typescript-node-release.yml

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,35 @@ jobs:
88
build-and-push:
99
runs-on: ubuntu-latest
1010
environment: PRODUCTION
11+
permissions:
12+
contents: read
13+
packages: write
14+
env:
15+
REPO: typescript-node
1116
steps:
12-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
1318

1419
- name: Set up QEMU
15-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # 3.6.0
20+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # 3.7.0
1621

1722
- name: Set up Docker Buildx
18-
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
23+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # 3.12.0
1924

2025
- name: Login to Docker Hub
21-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
26+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # 3.6.0
2227
with:
2328
username: ${{ vars.DOCKERHUB_USERNAME }}
2429
password: ${{ secrets.DOCKERHUB_TOKEN }}
2530

2631
- name: Login to GHCR
27-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
32+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # 3.6.0
2833
with:
2934
registry: ghcr.io
3035
username: ${{ github.repository_owner }}
31-
password: ${{ secrets.GH_TOKEN }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
3237

33-
- name: Generate build tag
38+
- id: tag_builder
39+
name: Generate build tags
3440
run: |
3541
RELEASE_NAME="${{ github.event.release.name }}"
3642
@@ -43,22 +49,75 @@ jobs:
4349
if [[ "$RELEASE_NAME" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
4450
# Strip 'v' prefix if present
4551
CLEAN_VERSION="${RELEASE_NAME#v}"
46-
echo "BUILD_TAG=$CLEAN_VERSION" >> $GITHUB_ENV
52+
echo "build_tag=$CLEAN_VERSION" >> $GITHUB_OUTPUT
4753
else
4854
echo "Error: Release name '$RELEASE_NAME' is not a valid semantic version"
4955
exit 1
5056
fi
5157
58+
# expose a separate tag for testing purposes
59+
TIMESTAMP=$(date +'%Y%m%d')
60+
SHA=$(git rev-parse --short HEAD)
61+
echo "test_tag=test-${TIMESTAMP}-${SHA}" >> $GITHUB_OUTPUT
62+
63+
- name: Build image for testing
64+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
65+
with:
66+
context: source/typescript-node
67+
platforms: linux/amd64,linux/arm64
68+
push: false
69+
load: true
70+
tags: |
71+
${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO }}:${{ steps.tag_builder.outputs.test_tag }}
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max
74+
75+
- name: Run test
76+
run: |
77+
TEST_IMAGE="${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO }}:${{ steps.tag_builder.outputs.test_tag }}"
78+
echo "Running smoke test against $TEST_IMAGE"
79+
docker run --rm "$TEST_IMAGE" node -v
80+
81+
- id: image_reference_builder
82+
name: Generate image references
83+
env:
84+
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
85+
REPO_OWNER: ${{ github.repository_owner }}
86+
run: |
87+
NEW_TAG="${{ steps.tag_builder.outputs.build_tag }}"
88+
NEW_MAJOR=$(echo "$NEW_TAG" | cut -d. -f1)
89+
REPO="$GITHUB_REPOSITORY"
90+
91+
LATEST_TAG_NAME=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${REPO}/releases/latest" | python -c 'import sys,json;print(json.load(sys.stdin).get("tag_name","") or "")')
92+
LATEST_CLEAN="${LATEST_TAG_NAME#v}"
93+
if [ -z "$LATEST_CLEAN" ]; then
94+
LATEST_MAJOR=-1
95+
else
96+
LATEST_MAJOR=$(echo "$LATEST_CLEAN" | cut -d. -f1)
97+
fi
98+
99+
echo "New major: $NEW_MAJOR, Latest major: $LATEST_MAJOR"
100+
101+
REFS="${DOCKERHUB_USERNAME}/${REPO}:${NEW_TAG}\nghcr.io/${REPO_OWNER}/${REPO}:${NEW_TAG}"
102+
if [ "$NEW_MAJOR" -gt "$LATEST_MAJOR" ]; then
103+
echo "Tagging as latest (major increased)"
104+
REFS="${REFS}\n${DOCKERHUB_USERNAME}/${REPO}:latest\nghcr.io/${REPO_OWNER}/${REPO}:latest"
105+
else
106+
echo "Not tagging as latest (major not increased)"
107+
fi
108+
109+
printf "%b" "$REFS" >> $GITHUB_ENV
110+
111+
echo "image_references<<EOF" >> $GITHUB_OUTPUT
112+
printf "%b" "$REFS" >> $GITHUB_OUTPUT
113+
echo "EOF" >> $GITHUB_OUTPUT
114+
52115
- name: Build & Push image to registries
53-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
116+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
54117
with:
55118
context: source/typescript-node
56119
platforms: linux/amd64,linux/arm64
57120
push: true
58-
tags: |
59-
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ env.BUILD_TAG }}
60-
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:latest
61-
ghcr.io/${{ github.repository_owner }}/typescript-node:${{ env.BUILD_TAG }}
62-
ghcr.io/${{ github.repository_owner }}/typescript-node:latest
121+
tags: ${{ steps.image_reference_builder.outputs.image_references }}
63122
cache-from: type=gha
64123
cache-to: type=gha,mode=max

source/typescript-node/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Opinionated `Dockerfile` for Node.js and TypeScript development. This image includes a set of common tools and configurations for a smooth development experience.
66

7-
- This image is built on top of the [Node.js](https://hub.docker.com/_/node) base image. Default image variant is `22-bookworm-slim`, which is based on the latest LTS version of Node.js (22.x) and Debian Bookworm.
7+
- This image is built on top of the [Node.js](https://hub.docker.com/_/node) base image. Default image variant is `24-bookworm-slim`, which is based on the latest LTS version of Node.js (24.x) and Debian Bookworm.
88
- [How to choose Node.js container image](https://labs.iximiuz.com/tutorials/how-to-choose-nodejs-container-image)
99
- [Choosing the best Node.js Docker image](https://snyk.io/blog/choosing-the-best-node-js-docker-image/)
1010
- Package Manager is set up through corepack, [PNPM](https://pnpm.io/) is enabled and configured by default.
@@ -15,7 +15,7 @@ Opinionated `Dockerfile` for Node.js and TypeScript development. This image incl
1515

1616
| Argument | Description | Type | Default Value |
1717
|----------|-------------|------|---------------|
18-
| VARIANT | The image variant to use. See [supported tags](https://hub.docker.com/_/node) | `string` | `22-bookworm-slim` |
18+
| VARIANT | The image variant to use. See [supported tags](https://hub.docker.com/_/node) | `string` | `24-bookworm-slim` |
1919

2020
## Using this image
2121

0 commit comments

Comments
 (0)