1+ version : 2.1
2+
3+ orbs :
4+ gcp-cli : circleci/gcp-cli@3.0.1
5+ slack : circleci/slack@4.10.1
6+
7+ commands :
8+ gcp-oidc-authenticate :
9+ description : " Authenticate with GCP using a CircleCI OIDC token."
10+ parameters :
11+ project_id :
12+ type : env_var_name
13+ default : GCP_PROJECT_ID
14+ workload_identity_pool_id :
15+ type : env_var_name
16+ default : GCP_WIP_ID
17+ workload_identity_pool_provider_id :
18+ type : env_var_name
19+ default : GCP_WIP_PROVIDER_ID
20+ service_account_email :
21+ type : env_var_name
22+ default : GCP_SERVICE_ACCOUNT_EMAIL
23+ gcp_cred_config_file_path :
24+ type : string
25+ default : /home/circleci/gcp_cred_config.json
26+ oidc_token_file_path :
27+ type : string
28+ default : /home/circleci/oidc_token.json
29+ steps :
30+ - run :
31+ name : " Create OIDC credential configuration"
32+ command : |
33+ # Store OIDC token in temp file
34+ echo $CIRCLE_OIDC_TOKEN > << parameters.oidc_token_file_path >>
35+ # Create a credential configuration for the generated OIDC ID Token
36+ gcloud iam workload-identity-pools create-cred-config \
37+ "projects/${<< parameters.project_id >>}/locations/global/workloadIdentityPools/${<< parameters.workload_identity_pool_id >>}/providers/${<< parameters.workload_identity_pool_provider_id >>}"\
38+ --output-file="<< parameters.gcp_cred_config_file_path >>" \
39+ --service-account="${<< parameters.service_account_email >>}" \
40+ --credential-source-file=<< parameters.oidc_token_file_path >>
41+ - run :
42+ name : " Authenticate with GCP using OIDC"
43+ command : |
44+ # Configure gcloud to leverage the generated credential configuration
45+ gcloud auth login --brief --cred-file "<< parameters.gcp_cred_config_file_path >>"
46+ # Configure ADC
47+ echo "export GOOGLE_APPLICATION_CREDENTIALS='<< parameters.gcp_cred_config_file_path >>'" | tee -a "$BASH_ENV"
48+ jobs :
49+ docker-release :
50+ environment :
51+ DOCKER_BUILDKIT : 1
52+ parameters :
53+ docker_name :
54+ description : Docker image name
55+ type : string
56+ default : " op-geth"
57+ docker_tags :
58+ description : Docker image tags as csv
59+ type : string
60+ registry :
61+ description : Docker registry
62+ type : string
63+ default : " us-docker.pkg.dev"
64+ repo :
65+ description : Docker repo
66+ type : string
67+ default : " oplabs-tools-artifacts/images"
68+ push_tags :
69+ description : Push release push tags
70+ type : boolean
71+ default : false
72+ machine :
73+ image : ubuntu-2204:2022.07.1
74+ resource_class : xlarge
75+ steps :
76+ - gcp-cli/install
77+ - gcp-oidc-authenticate
78+ - checkout
79+ - run :
80+ name : Configure Docker
81+ command : |
82+ gcloud auth configure-docker <<parameters.registry>>
83+ - run :
84+ name : Build and push
85+ command : |
86+ RAW_TAGS="<<parameters.docker_tags>>"
87+ if [ "$CIRCLE_BRANCH" = "optimism" ]; then
88+ RAW_TAGS="$RAW_TAGS,optimism"
89+ fi
90+ IMAGE_BASE="<<parameters.registry>>/<<parameters.repo>>/<<parameters.docker_name>>"
91+ DOCKER_TAGS=$(echo -ne "$RAW_TAGS" | sed "s/,/\n/g" | sed "s/[^a-zA-Z0-9\n.]/-/g" | sed -e "s|^|-t ${IMAGE_BASE}:|")
92+ docker context create buildx-build
93+ docker buildx create --use buildx-build
94+ docker buildx build --push \
95+ $(echo -ne $DOCKER_TAGS | tr '\n' ' ') \
96+ --platform=linux/arm64,linux/amd64 \
97+ --build-arg VERSION=$CIRCLE_TAG \
98+ --build-arg COMMIT=$CIRCLE_SHA \
99+ --build-arg BUILDNUM=$CIRCLE_BUILD_NUM \
100+ --progress plain \
101+ -f Dockerfile .
102+ - when :
103+ condition :
104+ equal : [ true, <<parameters.push_tags>> ]
105+ steps :
106+ - run :
107+ name : Tag
108+ command : |
109+ ./.circleci/ci-docker-tag-op-geth-release.sh <<parameters.registry>>/<<parameters.repo>> $CIRCLE_TAG $CIRCLE_SHA1
110+ build-geth :
111+ docker :
112+ - image : cimg/go:1.19
113+ resource_class : xlarge
114+ steps :
115+ - checkout
116+ - run :
117+ command : go run build/ci.go install
118+ unit-test :
119+ resource_class : xlarge
120+ docker :
121+ - image : cimg/go:1.19
122+ steps :
123+ - checkout
124+ - run :
125+ command : go run build/ci.go test
126+ lint-geth :
127+ resource_class : medium
128+ docker :
129+ - image : cimg/go:1.19
130+ steps :
131+ - checkout
132+ - run :
133+ command : go run build/ci.go lint
134+ check-releases :
135+ docker :
136+ - image : cimg/go:1.19
137+ steps :
138+ - checkout
139+ - run :
140+ command : .circleci/check-releases.sh
141+ - slack/notify :
142+ channel : C03N11M0BBN
143+ branch_pattern : optimism
144+ event : fail
145+ template : basic_fail_1
146+
147+
148+ workflows :
149+ main :
150+ jobs :
151+ - build-geth :
152+ name : Build geth
153+ - unit-test :
154+ name : Run unit tests for geth
155+ - lint-geth :
156+ name : Run linter over geth
157+ - docker-release :
158+ name : Push to Docker
159+ docker_tags : <<pipeline.git.revision>>
160+ context :
161+ - oplabs-gcr
162+ release :
163+ jobs :
164+ - hold :
165+ type : approval
166+ filters :
167+ tags :
168+ only : /^v.*/
169+ branches :
170+ ignore : /.*/
171+ - docker-release :
172+ name : Push to Docker (release)
173+ filters :
174+ tags :
175+ only : /^v.*/
176+ branches :
177+ ignore : /.*/
178+ docker_tags : <<pipeline.git.revision>>,<<pipeline.git.tag>>
179+ push_tags : true
180+ context :
181+ - oplabs-gcr-release
182+ requires :
183+ - hold
184+ scheduled :
185+ triggers :
186+ - schedule :
187+ # run daily
188+ cron : " 0 0 * * *"
189+ filters :
190+ branches :
191+ only : [ "optimism" ]
192+ jobs :
193+ - check-releases :
194+ name : Check for new upstream releases
195+ context : slack
0 commit comments