Skip to content

Commit

Permalink
CI - fix/enhance initial GH Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Mar 8, 2024
1 parent 7ea549a commit 8634ad6
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 14 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/maven-pulls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build Test PR

on:
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]

steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: |
mvn --no-transfer-progress -B install --file pom.xml
36 changes: 36 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Test master

on:
push:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11 ]

steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: |
mvn --no-transfer-progress -B install --file pom.xml
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ jobs:
branch: bump-snap-${{ env.SC_NEXT_VERSION }}-SNAPSHOT
- name: deploy docker
run: |
SC_RELEASE_TAG="v${{ env.SC_VERSION }}"
SC_RELEASE_TAG="${{ env.SC_VERSION }}"
echo "$SC_RELEASE_TAG"
TOKEN="${{ secrets.RANCHER2_BEARER_TOKEN }}"
RANCHER_HOST="rancher.tools.swagger.io"
CLUSTER_ID="c-n8zp2"
NAMESPACE_NAME="swagger-oss"
K8S_OBJECT_TYPE="daemonsets"
K8S_OBJECT_NAME="swagger-petstore3"
DEPLOY_IMAGE="swaggerapi/swagger-petstore3:$SC_RELEASE_TAG"
K8S_OBJECT_NAME="swagger-petstore-3"
DEPLOY_IMAGE="swaggerapi/petstore3:$SC_RELEASE_TAG"
workloadStatus=""
getStatus() {
Expand Down
2 changes: 1 addition & 1 deletion CI/docker-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

CUR=$(pwd)

SC_RELEASE_TAG="v$SC_VERSION"
SC_RELEASE_TAG="$SC_VERSION"

echo "docker tag:"
echo "$SC_RELEASE_TAG"
Expand Down
7 changes: 4 additions & 3 deletions CI/lastRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ def getLastReleaseTag():
for l in content:
draft = l["draft"]
tag = l["tag_name"]
if str(draft) != 'True' and tag.startswith("v2"):
return tag[1:]
return "v2.1.3"
if str(draft) != 'True' and tag.startswith("swagger-petstore-v3-"):
return tag
print ("NO RELEASE TAG FOUND, using default swagger-petstore-v3-1.0.17")
return "swagger-petstore-v3-1.0.17"
# main
def main():
result = getLastReleaseTag()
Expand Down
2 changes: 1 addition & 1 deletion CI/post-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CUR=$(pwd)
TMPDIR="$(dirname -- "${0}")"

SC_RELEASE_TAG="v$SC_VERSION"
SC_RELEASE_TAG="swagger-petstore-v3-$SC_VERSION"

#####################
### publish pre-prepared release (tag is created)
Expand Down
2 changes: 1 addition & 1 deletion CI/pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SC_QUALIFIER=`mvn -q -Dexec.executable="echo" -Dexec.args='${parsedVersion.quali
SC_LAST_RELEASE=`python $CUR/CI/lastRelease.py`


SC_RELEASE_TAG="v$SC_VERSION"
SC_RELEASE_TAG="$SC_VERSION"


#####################
Expand Down
11 changes: 9 additions & 2 deletions CI/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SC_LAST_RELEASE=`python $CUR/CI/lastRelease.py`



SC_RELEASE_TITLE="Swagger-Petstore $SC_VERSION released!"
SC_RELEASE_TAG="v$SC_VERSION"
SC_RELEASE_TITLE="Swagger Petstore OpenAPI 3.0 release $SC_VERSION"
SC_RELEASE_TAG="swagger-petstore-v3-$SC_VERSION"

echo "SC_VERSION: $SC_VERSION"
echo "SC_NEXT_VERSION: $SC_NEXT_VERSION"
Expand All @@ -24,6 +24,13 @@ echo "SC_RELEASE_TAG: $SC_RELEASE_TAG"
#####################
python $CUR/CI/releaseNotes.py "$SC_LAST_RELEASE" "$SC_RELEASE_TITLE" "$SC_RELEASE_TAG"

#####################
### update version in openapi.yaml file ###
#####################
sc_find="version\: $SC_VERSION\-SNAPSHOT"
sc_replace="version: $SC_VERSION"
sed -i -e "s/$sc_find/$sc_replace/g" $CUR/src/main/resources/openapi.yaml

#####################
### build and test maven ###
#####################
Expand Down
2 changes: 1 addition & 1 deletion CI/releaseNotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def getReleases():

# main
def main(last_release, release_title, tag):
result = allPulls(lastReleaseDate('v' + last_release))
result = allPulls(lastReleaseDate(last_release))
addRelease (release_title, tag, result)

# here start main
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>swagger-petstore</artifactId>
<packaging>war</packaging>
<name>swagger-petstore</name>
<version>1.0.17</version>
<version>1.0.18-SNAPSHOT</version>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ info:
Some useful links:
- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
- [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
version: 1.0.17
version: 1.0.18-SNAPSHOT
title: Swagger Petstore - OpenAPI 3.0
termsOfService: 'http://swagger.io/terms/'
contact:
Expand Down

0 comments on commit 8634ad6

Please sign in to comment.