Skip to content

Commit 612f1d4

Browse files
authored
Merge branch 'master' into chrisdrifte-fix-typescript-fetch-build
2 parents 55f5016 + c8ab7ac commit 612f1d4

File tree

322 files changed

+5790
-3524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

322 files changed

+5790
-3524
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
ignore:
8+
- dependency-name: "*"
9+
update-types: ["version-update:semver-major"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Dependency Review'
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
dependency-review:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: 'Checkout Repository'
12+
uses: actions/checkout@v4
13+
- name: Dependency Review
14+
uses: actions/dependency-review-action@v3
15+
with:
16+
fail-on-severity: high

.github/workflows/docker-release-3.0.yml

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,129 @@ jobs:
6767
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest
6868
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}
6969
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:latest
70+
echo "docker images:"
71+
docker images | grep -i generator
72+
echo "pushing $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }}"
7073
docker push $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }}
74+
echo "pushing $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:latest"
7175
docker push $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:latest
76+
echo "tagging $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root"
7277
docker tag $DOCKER_GENERATOR_ROOT_FULL_IMAGE_NAME:${{ env.TAG }} $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root
73-
docker push $DOCKER_GENERATOR_FULL_IMAGE_NAME:$${{ env.TAG }}-root
78+
echo "pushing $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root"
79+
docker -D -l debug push $DOCKER_GENERATOR_FULL_IMAGE_NAME:${{ env.TAG }}-root
80+
- name: deploy
81+
run: |
82+
echo "${{ env.TAG }}"
83+
84+
TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
85+
RANCHER_HOST="rancher.tools.swagger.io"
86+
CLUSTER_ID="c-n8zp2"
87+
NAMESPACE_NAME="swagger-oss"
88+
K8S_OBJECT_TYPE="daemonsets"
89+
K8S_OBJECT_NAME="swagger-generator-v3"
90+
DEPLOY_IMAGE="swaggerapi/swagger-generator-v3:${{ env.TAG }}"
91+
92+
workloadStatus=""
93+
getStatus() {
94+
echo "Getting update status..."
95+
if ! workloadStatus="$(curl -s -X GET \
96+
-H "Authorization: Bearer ${TOKEN}" \
97+
-H 'Content-Type: application/json' \
98+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}/status")"
99+
then
100+
echo 'ERROR - get status k8s API call failed!'
101+
echo "Exiting build"...
102+
exit 1
103+
fi
104+
}
105+
106+
# $1 = image to deploy
107+
updateObject() {
108+
local image="${1}"
109+
echo "Updating image value..."
110+
111+
if ! curl -s -X PATCH \
112+
-H "Authorization: Bearer ${TOKEN}" \
113+
-H 'Content-Type: application/json-patch+json' \
114+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}" \
115+
-d "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/image\", \"value\": \"${image}\"}]"
116+
then
117+
echo 'ERROR - image update k8s API call failed!'
118+
echo "Exiting build..."
119+
exit 1
120+
fi
121+
}
122+
123+
124+
# Check that the TAG is valid
125+
if [[ ${{ env.TAG }} =~ ^[vV]?[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
126+
echo ""
127+
echo "This is a Valid TAG..."
128+
129+
# Get current image/tag in case we need to rollback
130+
getStatus
131+
ROLLBACK_IMAGE="$(echo "${workloadStatus}" | jq -r '.spec.template.spec.containers[0].image')"
132+
echo ""
133+
echo "Current image: ${ROLLBACK_IMAGE}"
134+
135+
# Update image and validate response
136+
echo ""
137+
updateObject "${DEPLOY_IMAGE}"
138+
echo ""
139+
140+
echo ""
141+
echo "Waiting for pods to start..."
142+
echo ""
143+
sleep 60s
144+
145+
# Get state of the k8s object. If numberReady == desiredNumberScheduled, consider the upgrade successful. Else raise error
146+
getStatus
147+
status="$(echo "${workloadStatus}" | jq '.status')"
148+
echo ""
149+
echo "${status}"
150+
echo ""
151+
152+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
153+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
154+
155+
if (( numberReady == numberDesired )); then
156+
echo "${K8S_OBJECT_NAME} has been upgraded to ${DEPLOY_IMAGE}"
157+
158+
# If pods are not starting, rollback the upgrade and exit the build with error
159+
else
160+
echo "state = error...rolling back upgrade"
161+
updateObject "${ROLLBACK_IMAGE}"
162+
echo ""
163+
164+
echo ""
165+
echo "Waiting for rollback pods to start..."
166+
echo ""
167+
sleep 60s
168+
169+
getStatus
170+
status="$(echo "${workloadStatus}" | jq '.status')"
171+
echo ""
172+
echo "${status}"
173+
echo ""
174+
175+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
176+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
177+
178+
if (( numberReady == numberDesired )); then
179+
echo "Rollback to ${ROLLBACK_IMAGE} completed."
180+
else
181+
echo "FATAL - rollback failed"
182+
fi
183+
echo "Exiting Build..."
184+
exit 1
185+
fi
186+
187+
else
188+
echo "This TAG is not in a valid format..."
189+
echo "Exiting Build..."
190+
exit 0
191+
fi
192+
echo "Exiting Build..."
193+
exit 0
74194
env:
75195
TAG: ${{ github.event.inputs.tag }}
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Build And Push Docker Release Master
2+
3+
on:
4+
workflow_dispatch:
5+
branches: [ "master" ]
6+
inputs:
7+
tag:
8+
description: tag/version to release
9+
required: true
10+
jobs:
11+
build_push_docker_release_master:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
name: git checkout master
18+
with:
19+
ref: master
20+
- name: Set up Java
21+
uses: actions/setup-java@v3
22+
with:
23+
java-version: 17
24+
distribution: temurin
25+
cache: maven
26+
- name: preliminary checks
27+
run: |
28+
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
29+
set -e
30+
# fail if templates/generators contain carriage return '\r'
31+
/bin/bash ./bin/utils/detect_carriage_return.sh
32+
# fail if generators contain merge conflicts
33+
/bin/bash ./bin/utils/detect_merge_conflict.sh
34+
# fail if generators contain tab '\t'
35+
/bin/bash ./bin/utils/detect_tab_in_java_class.sh
36+
- uses: s4u/[email protected]
37+
name: setup maven settings.xml
38+
with:
39+
servers: |
40+
[{
41+
"id": "sonatype-nexus-staging",
42+
"username": "${{ secrets.OSSRH_USERNAME }}",
43+
"password": "${{ secrets.OSSRH_TOKEN }}"
44+
},
45+
{
46+
"id": "sonatype-nexus-snapshots",
47+
"username": "${{ secrets.OSSRH_USERNAME }}",
48+
"password": "${{ secrets.OSSRH_TOKEN }}"
49+
}]
50+
- name: Build with Maven
51+
run: |
52+
mvn clean install -U
53+
- name: docker build and push
54+
run: |
55+
export DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator
56+
export DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli
57+
export MY_POM_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
58+
59+
docker build --rm=false -t $DOCKER_GENERATOR_IMAGE_NAME:${{ env.TAG }} ./modules/swagger-generator
60+
docker tag $DOCKER_GENERATOR_IMAGE_NAME:${{ env.TAG }} $DOCKER_GENERATOR_IMAGE_NAME:latest
61+
docker push $DOCKER_GENERATOR_IMAGE_NAME:${{ env.TAG }}
62+
docker push $DOCKER_GENERATOR_IMAGE_NAME:latest
63+
docker build --rm=false -t $DOCKER_CODEGEN_CLI_IMAGE_NAME:${{ env.TAG }} ./modules/swagger-codegen-cli
64+
docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:${{ env.TAG }} $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest
65+
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:${{ env.TAG }}
66+
docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest
67+
- name: deploy
68+
run: |
69+
echo "${{ env.TAG }}"
70+
71+
TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
72+
RANCHER_HOST="rancher.tools.swagger.io"
73+
CLUSTER_ID="c-n8zp2"
74+
NAMESPACE_NAME="swagger-oss"
75+
K8S_OBJECT_TYPE="daemonsets"
76+
K8S_OBJECT_NAME="swagger-generator"
77+
DEPLOY_IMAGE="swaggerapi/swagger-generator:${{ env.TAG }}"
78+
79+
workloadStatus=""
80+
getStatus() {
81+
echo "Getting update status..."
82+
if ! workloadStatus="$(curl -s -X GET \
83+
-H "Authorization: Bearer ${TOKEN}" \
84+
-H 'Content-Type: application/json' \
85+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}/status")"
86+
then
87+
echo 'ERROR - get status k8s API call failed!'
88+
echo "Exiting build"...
89+
exit 1
90+
fi
91+
}
92+
93+
# $1 = image to deploy
94+
updateObject() {
95+
local image="${1}"
96+
echo "Updating image value..."
97+
98+
if ! curl -s -X PATCH \
99+
-H "Authorization: Bearer ${TOKEN}" \
100+
-H 'Content-Type: application/json-patch+json' \
101+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}" \
102+
-d "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/image\", \"value\": \"${image}\"}]"
103+
then
104+
echo 'ERROR - image update k8s API call failed!'
105+
echo "Exiting build..."
106+
exit 1
107+
fi
108+
}
109+
110+
111+
# Check that the TAG is valid
112+
if [[ ${{ env.TAG }} =~ ^[vV]?[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
113+
echo ""
114+
echo "This is a Valid TAG..."
115+
116+
# Get current image/tag in case we need to rollback
117+
getStatus
118+
ROLLBACK_IMAGE="$(echo "${workloadStatus}" | jq -r '.spec.template.spec.containers[0].image')"
119+
echo ""
120+
echo "Current image: ${ROLLBACK_IMAGE}"
121+
122+
# Update image and validate response
123+
echo ""
124+
updateObject "${DEPLOY_IMAGE}"
125+
echo ""
126+
127+
echo ""
128+
echo "Waiting for pods to start..."
129+
echo ""
130+
sleep 60s
131+
132+
# Get state of the k8s object. If numberReady == desiredNumberScheduled, consider the upgrade successful. Else raise error
133+
getStatus
134+
status="$(echo "${workloadStatus}" | jq '.status')"
135+
echo ""
136+
echo "${status}"
137+
echo ""
138+
139+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
140+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
141+
142+
if (( numberReady == numberDesired )); then
143+
echo "${K8S_OBJECT_NAME} has been upgraded to ${DEPLOY_IMAGE}"
144+
145+
# If pods are not starting, rollback the upgrade and exit the build with error
146+
else
147+
echo "state = error...rolling back upgrade"
148+
updateObject "${ROLLBACK_IMAGE}"
149+
echo ""
150+
151+
echo ""
152+
echo "Waiting for rollback pods to start..."
153+
echo ""
154+
sleep 60s
155+
156+
getStatus
157+
status="$(echo "${workloadStatus}" | jq '.status')"
158+
echo ""
159+
echo "${status}"
160+
echo ""
161+
162+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
163+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
164+
165+
if (( numberReady == numberDesired )); then
166+
echo "Rollback to ${ROLLBACK_IMAGE} completed."
167+
else
168+
echo "FATAL - rollback failed"
169+
fi
170+
echo "Exiting Build..."
171+
exit 1
172+
fi
173+
174+
else
175+
echo "This TAG is not in a valid format..."
176+
echo "Exiting Build..."
177+
exit 0
178+
fi
179+
echo "Exiting Build..."
180+
exit 0
181+
env:
182+
TAG: ${{ github.event.inputs.tag }}

0 commit comments

Comments
 (0)