-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (124 loc) · 5.06 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: release
run-name: ${{ github.actor }} has triggered a build and push of the Terascope Base Image
on:
release:
types: [published]
schedule:
- cron: '30 5 * * 0' # Sunday's at 0530
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/node-base
jobs:
build_and_release_matrix:
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
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64,linux/amd64
-
name: Get timestamp for docker build
id: docker_time_stamp
run: echo "BUILD_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")" >> $GITHUB_ENV
-
name: Build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64,linux/amd64
build-args: |
"NODE_VERSION=${{ matrix.version }}"
"GITHUB_SHA=${{ github.sha }}"
"BUILD_TIMESTAMP=${{ env.BUILD_TIMESTAMP }}"
provenance: false
sbom: false
pull: true
push: true
file: ./Dockerfile
tags: "${{ env.IMAGE_NAME }}:${{ matrix.version }}"
-
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: 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.
# -
# 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
# - 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