Skip to content

Commit 8f05c31

Browse files
committed
add CI release Worflow for 3.0.0
1 parent c73692e commit 8f05c31

File tree

4 files changed

+297
-5
lines changed

4 files changed

+297
-5
lines changed

.github/workflows/release-full-3.yml

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
name: Release Codegen 3.0 and Generators
2+
3+
on:
4+
workflow_dispatch:
5+
branches: [ "3.0.0" ]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout swagger-codegen (3.0.0)
12+
uses: actions/checkout@v4
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
ref: 3.0.0
16+
17+
- name: Checkout swagger-codegen-generators
18+
uses: actions/checkout@v4
19+
with:
20+
repository: swagger-api/swagger-codegen-generators
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
ref: master
23+
path: generators-repo
24+
- uses: tibdex/github-app-token@v2
25+
id: generate-token
26+
with:
27+
app_id: ${{ secrets.APP_ID }}
28+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
29+
- name: Set up Java and Maven
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '17'
33+
distribution: 'temurin'
34+
server-id: central
35+
server-username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
36+
server-password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
37+
gpg-private-key: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
38+
- name: Cache Maven repository
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.m2/repository
42+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
43+
- name: configure git user email
44+
run: |
45+
git config --global user.email "action@github.com"
46+
git config --global user.name "GitHub Action"
47+
git config --global hub.protocol https
48+
git remote set-url origin https://\${{ secrets.GITHUB_TOKEN }}:x-oauth-basic@github.com/swagger-api/swagger-codegen.git
49+
- name: Check Release Version codegen
50+
id: preRelease
51+
run: |
52+
# export GPG_TTY=$(tty)
53+
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`
54+
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
55+
then
56+
echo "not releasing snapshot version: " ${MY_POM_VERSION}
57+
echo "RELEASE_OK=no" >> $GITHUB_ENV
58+
else
59+
echo "RELEASE_OK=yes" >> $GITHUB_ENV
60+
fi
61+
echo "SC_VERSION=$MY_POM_VERSION" >> $GITHUB_ENV
62+
- name: Check Release Version codegen-generators
63+
id: preRelease generators
64+
if: env.RELEASE_OK == 'yes'
65+
working-directory: generators-repo
66+
run: |
67+
# export GPG_TTY=$(tty)
68+
export MY_POM_VERSION_GENERATORS=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
69+
if [[ $MY_POM_VERSION_GENERATORS =~ ^.*SNAPSHOT$ ]];
70+
then
71+
echo "not releasing snapshot version: " ${MY_POM_VERSION_GENERATORS}
72+
echo "RELEASE_OK=no" >> $GITHUB_ENV
73+
else
74+
echo "RELEASE_OK=yes" >> $GITHUB_ENV
75+
fi
76+
echo "SC_VERSION_GENERATORS=$MY_POM_VERSION_GENERATORS" >> $GITHUB_ENV
77+
- name: Run maven install for codegen-generators
78+
if: env.RELEASE_OK == 'yes'
79+
working-directory: generators-repo
80+
run: |
81+
SNAP_API="https://central.sonatype.com/repository/maven-snapshots"
82+
ARTIFACT_PATH="io/swagger/codegen/v3/swagger-codegen"
83+
ROOT_META="${SNAP_API}/${ARTIFACT_PATH}/maven-metadata.xml"
84+
export LAST_SNAP=$(curl -s "$ROOT_META" | grep -oP '(?<=<version>)3\.[^<]+' | sort -V | tail -n1)
85+
echo "LAST_SNAP $LAST_SNAP"
86+
export CODEGEN_VERSION_PROPERTY=-Dswagger-codegen-version=$LAST_SNAP
87+
mvn clean install -U ${CODEGEN_VERSION_PROPERTY}
88+
- name: Run maven install for codegen
89+
if: env.RELEASE_OK == 'yes'
90+
run: |
91+
SNAP_API="https://central.sonatype.com/repository/maven-snapshots"
92+
ARTIFACT_PATH="io/swagger/codegen/v3/swagger-codegen-generators"
93+
ROOT_META="${SNAP_API}/${ARTIFACT_PATH}/maven-metadata.xml"
94+
export LAST_SNAP=$(curl -s "$ROOT_META" | grep -oP '(?<=<version>)1\.[^<]+' | sort -V | tail -n1)
95+
echo "LAST_SNAP $LAST_SNAP"
96+
export GENERATORS_VERSION_PROPERTY=-Dswagger-codegen-generators-version=$LAST_SNAP
97+
mvn clean install -U -Pdocker -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089 ${GENERATORS_VERSION_PROPERTY}
98+
- name: Run maven deploy/release for codegen-generators
99+
if: env.RELEASE_OK == 'yes'
100+
working-directory: generators-repo
101+
run: |
102+
mvn --no-transfer-progress -B -Prelease deploy
103+
- name: Run maven deploy/release for codegen
104+
if: env.RELEASE_OK == 'yes'
105+
run: |
106+
mvn --no-transfer-progress -B -Prelease deploy
107+
- name: Set up QEMU
108+
uses: docker/setup-qemu-action@v3
109+
- name: Set up Docker Buildx
110+
uses: docker/setup-buildx-action@v3
111+
- name: preliminary checks
112+
run: |
113+
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
114+
set -e
115+
- name: Build with Maven
116+
run: |
117+
mvn clean install -U -Pdocker -DJETTY_TEST_HTTP_PORT=8090 -DJETTY_TEST_STOP_PORT=8089
118+
- name: docker generator build and push
119+
if: env.RELEASE_OK == 'yes'
120+
uses: docker/build-push-action@v5
121+
with:
122+
context: ./modules/swagger-generator
123+
file: ./modules/swagger-generator/Dockerfile
124+
push: true
125+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
126+
provenance: false
127+
build-args: |
128+
HIDDEN_OPTIONS_DEFAULT_PATH=hiddenOptions.yaml
129+
JAVA_MEM=1024m
130+
HTTP_PORT=8080
131+
tags: swaggerapi/swagger-generator-v3:${{ env.SC_VERSION }},swaggerapi/swagger-generator-v3:latest
132+
- name: docker generator root build and push
133+
if: env.RELEASE_OK == 'yes'
134+
uses: docker/build-push-action@v5
135+
with:
136+
context: ./modules/swagger-generator
137+
file: ./modules/swagger-generator/Dockerfile_root
138+
push: true
139+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
140+
provenance: false
141+
build-args: |
142+
HIDDEN_OPTIONS_DEFAULT_PATH=hiddenOptions.yaml
143+
JAVA_MEM=1024m
144+
HTTP_PORT=8080
145+
tags: swaggerapi/swagger-generator-v3-root:${{ env.SC_VERSION }},swaggerapi/swagger-generator-v3-root:latest
146+
- name: docker cli build and push
147+
if: env.RELEASE_OK == 'yes'
148+
uses: docker/build-push-action@v5
149+
with:
150+
context: ./modules/swagger-generator
151+
file: ./modules/swagger-generator/Dockerfile_minimal
152+
push: true
153+
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
154+
provenance: false
155+
tags: swaggerapi/swagger-codegen-cli-v3:${{ env.SC_VERSION }},swaggerapi/swagger-codegen-cli-v3:latest
156+
- name: docker minimal build and push
157+
if: env.RELEASE_OK == 'yes'
158+
uses: docker/build-push-action@v5
159+
with:
160+
context: ./modules/swagger-generator
161+
file: ./modules/swagger-generator/Dockerfile_minimal
162+
push: true
163+
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
164+
provenance: false
165+
tags: swaggerapi/swagger-generator-v3-minimal:${{ env.SC_VERSION }},swaggerapi/swagger-generator-v3-minimal:latest
166+
- name: deploy
167+
run: |
168+
echo "${{ env.SC_VERSION }}"
169+
170+
TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
171+
RANCHER_HOST="rancher.tools.swagger.io"
172+
CLUSTER_ID="c-n8zp2"
173+
NAMESPACE_NAME="swagger-oss"
174+
K8S_OBJECT_TYPE="daemonsets"
175+
K8S_OBJECT_NAME="swagger-generator-v3"
176+
DEPLOY_IMAGE="swaggerapi/swagger-generator-v3:${{ env.SC_VERSION }}"
177+
178+
workloadStatus=""
179+
getStatus() {
180+
echo "Getting update status..."
181+
if ! workloadStatus="$(curl -s -X GET \
182+
-H "Authorization: Bearer ${TOKEN}" \
183+
-H 'Content-Type: application/json' \
184+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}/status")"
185+
then
186+
echo 'ERROR - get status k8s API call failed!'
187+
echo "Exiting build"...
188+
exit 1
189+
fi
190+
}
191+
192+
# $1 = image to deploy
193+
updateObject() {
194+
local image="${1}"
195+
echo "Updating image value..."
196+
197+
if ! curl -s -X PATCH \
198+
-H "Authorization: Bearer ${TOKEN}" \
199+
-H 'Content-Type: application/json-patch+json' \
200+
"https://${RANCHER_HOST}/k8s/clusters/${CLUSTER_ID}/apis/apps/v1/namespaces/${NAMESPACE_NAME}/${K8S_OBJECT_TYPE}/${K8S_OBJECT_NAME}" \
201+
-d "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/image\", \"value\": \"${image}\"}]"
202+
then
203+
echo 'ERROR - image update k8s API call failed!'
204+
echo "Exiting build..."
205+
exit 1
206+
fi
207+
}
208+
209+
210+
# Check that the TAG is valid
211+
if [[ ${{ env.SC_VERSION }} =~ ^[vV]?[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
212+
echo ""
213+
echo "This is a Valid TAG..."
214+
215+
# Get current image/tag in case we need to rollback
216+
getStatus
217+
ROLLBACK_IMAGE="$(echo "${workloadStatus}" | jq -r '.spec.template.spec.containers[0].image')"
218+
echo ""
219+
echo "Current image: ${ROLLBACK_IMAGE}"
220+
221+
# Update image and validate response
222+
echo ""
223+
updateObject "${DEPLOY_IMAGE}"
224+
echo ""
225+
226+
echo ""
227+
echo "Waiting for pods to start..."
228+
echo ""
229+
sleep 60s
230+
231+
# Get state of the k8s object. If numberReady == desiredNumberScheduled, consider the upgrade successful. Else raise error
232+
getStatus
233+
status="$(echo "${workloadStatus}" | jq '.status')"
234+
echo ""
235+
echo "${status}"
236+
echo ""
237+
238+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
239+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
240+
241+
if (( numberReady == numberDesired )); then
242+
echo "${K8S_OBJECT_NAME} has been upgraded to ${DEPLOY_IMAGE}"
243+
244+
# If pods are not starting, rollback the upgrade and exit the build with error
245+
else
246+
echo "state = error...rolling back upgrade"
247+
updateObject "${ROLLBACK_IMAGE}"
248+
echo ""
249+
250+
echo ""
251+
echo "Waiting for rollback pods to start..."
252+
echo ""
253+
sleep 60s
254+
255+
getStatus
256+
status="$(echo "${workloadStatus}" | jq '.status')"
257+
echo ""
258+
echo "${status}"
259+
echo ""
260+
261+
numberDesired="$(echo "${status}" | jq -r '.desiredNumberScheduled')"
262+
numberReady="$(echo "${status}" | jq -r '.numberReady')"
263+
264+
if (( numberReady == numberDesired )); then
265+
echo "Rollback to ${ROLLBACK_IMAGE} completed."
266+
else
267+
echo "FATAL - rollback failed"
268+
fi
269+
echo "Exiting Build..."
270+
exit 1
271+
fi
272+
273+
else
274+
echo "This TAG is not in a valid format..."
275+
echo "Exiting Build..."
276+
exit 0
277+
fi
278+
echo "Exiting Build..."
279+
exit 0
280+
env:
281+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
282+
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
283+
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
284+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
285+
SC_VERSION:
286+
SC_VERSION_GENERATORS:
287+
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
288+
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
5757

5858
Swagger Codegen Version | Release Date | Swagger / OpenAPI Spec compatibility | Notes
5959
-------------------------- |--------------| -------------------------- | -----
60-
[3.0.65](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.65) (**current stable**) | 2024-12-18 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.65](https://github.com/swagger-api/swagger-codegen/tree/v3.0.65)
60+
[3.0.69](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.69) (**current stable**) | 2025-06-18 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.69](https://github.com/swagger-api/swagger-codegen/tree/v3.0.69)
6161
[2.4.45](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.45) (**current stable**) | 2025-06-08 | 1.0, 1.1, 1.2, 2.0 | [tag v2.4.45](https://github.com/swagger-api/swagger-codegen/tree/v2.4.45)
6262

6363
💁 Here's also an overview of what's coming around the corner:
6464

6565
Swagger Codegen Version | Release Date | Swagger / OpenAPI Spec compatibility | Notes
6666
-------------------------- |--------------| -------------------------- | -----
67-
3.0.66-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.66-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
67+
3.0.70-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.70-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
6868
2.4.46-SNAPSHOT (current master, upcoming minor release) [SNAPSHOT](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/swagger/swagger-codegen-cli/2.4.46-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0 | Minor release
6969

7070
For detailed breakdown of all versions, please see the [full compatibility listing](./docs/compatibility.md).

docs/compatibility.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ The Swagger Codegen project has the following compatibilities with the OpenAPI S
44

55
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
66
-------------------------- |--------------| -------------------------- | -----
7-
3.0.66-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.66-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
8-
[3.0.65](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.65) (**current stable**) | 2024-12-18 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.65](https://github.com/swagger-api/swagger-codegen/tree/v3.0.65)
7+
3.0.70-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.70-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
8+
[3.0.69](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.69) (**current stable**) | 2025-06-18 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.69](https://github.com/swagger-api/swagger-codegen/tree/v3.0.69)
9+
[3.0.68](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.68) | 2025-03-05 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.68](https://github.com/swagger-api/swagger-codegen/tree/v3.0.68)
10+
[3.0.67](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.67) | 2025-01-27 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.67](https://github.com/swagger-api/swagger-codegen/tree/v3.0.67)
11+
[3.0.66](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.66) | 2024-12-23 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.66](https://github.com/swagger-api/swagger-codegen/tree/v3.0.66)
12+
[3.0.65](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.65) | 2024-12-18 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.65](https://github.com/swagger-api/swagger-codegen/tree/v3.0.65)
913
[3.0.64](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.64) | 2024-11-07 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.64](https://github.com/swagger-api/swagger-codegen/tree/v3.0.64)
1014
[3.0.63](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.63) | 2024-10-16 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.63](https://github.com/swagger-api/swagger-codegen/tree/v3.0.63)
1115
[3.0.62](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.62) | 2024-08-27 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.62](https://github.com/swagger-api/swagger-codegen/tree/v3.0.62)

docs/prerequisites.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.45/swagge
99
java -jar swagger-codegen-cli.jar help
1010

1111
# Download current stable 3.x.x branch (OpenAPI version 3)
12-
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.65/swagger-codegen-cli-3.0.65.jar -O swagger-codegen-cli.jar
12+
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.69/swagger-codegen-cli-3.0.69.jar -O swagger-codegen-cli.jar
1313

1414
java -jar swagger-codegen-cli.jar --help
1515
```

0 commit comments

Comments
 (0)