Skip to content

Commit

Permalink
introduce GitHub Actions for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Jul 22, 2020
1 parent c10e271 commit a3d368b
Show file tree
Hide file tree
Showing 24 changed files with 1,020 additions and 109 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/maven-pulls.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven
name: Build Test PR

on:
pull_request:
branches: [ master ]
branches: [ "master" ]

jobs:
build:
Expand All @@ -30,7 +27,7 @@ jobs:
${{ runner.os }}-maven-
- name: Build with Maven and Gradle
run: |
./mvnw -B install --file pom.xml
./mvnw --no-transfer-progress -B install --file pom.xml
cd ./modules/swagger-gradle-plugin
./gradlew build --info
cd ../..
29 changes: 29 additions & 0 deletions .github/workflows/maven-v1-pulls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build Test PR 1.5

on:
pull_request:
branches: [ "1.5" ]

jobs:
build:

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

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 and Gradle
run: ./mvnw --no-transfer-progress -B -Dhttps.protocols=TLSv1.2 verify --file pom.xml
46 changes: 46 additions & 0 deletions .github/workflows/maven-v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Test Deploy 1.5

on:
push:
branches: [ "1.5" ]
pull_request:
branches: [ "1.5" ]

jobs:
build:

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

steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
server-id: sonatype-nexus-snapshots
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 and Gradle
run: |
./mvnw --no-transfer-progress -B -Dhttps.protocols=TLSv1.2 verify --file pom.xml
export MY_POM_VERSION=`./mvnw -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
./mvnw --no-transfer-progress -B clean install # TODO this must be ./mvnw -B -Dhttps.protocols=TLSv1.2 clean deploy in real !!!!!!!!!!!!
else
echo "not deploying release: " ${MY_POM_VERSION}
fi
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
37 changes: 18 additions & 19 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven
name: Build Test Deploy master

on:
push:
branches: [ master ]
branches: [ "master" ]

jobs:
build:
Expand All @@ -21,7 +18,7 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
server-id: sonatype-nexus-snapshots
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Cache local Maven repository
Expand All @@ -33,24 +30,26 @@ jobs:
${{ runner.os }}-maven-
- name: Build with Maven and Gradle, Deploy snapshot to maven central
run: |
./mvnw -B install --file pom.xml
cd ./modules/swagger-gradle-plugin
./gradlew build --info
cd ../..
export MY_JAVA_VERSION=`java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
echo "JAVA VERSION" ${MY_JAVA_VERSION}
if [[ ${MY_JAVA_VERSION} == "8" ]];
export MY_POM_VERSION=`./mvnw -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
export MY_POM_VERSION=`./mvnw -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
./mvnw --no-transfer-progress -B install --file pom.xml
cd ./modules/swagger-gradle-plugin
./gradlew build --info
cd ../..
export MY_JAVA_VERSION=`java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
echo "JAVA VERSION" ${MY_JAVA_VERSION}
if [[ ${MY_JAVA_VERSION} == "8" ]];
then
./mvnw -B deploy
export MY_POM_VERSION=`./mvnw -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
./mvnw --no-transfer-progress -B clean deploy
else
echo "not deploying release: " ${MY_POM_VERSION}
echo "not deploying on java version: " ${MY_JAVA_VERSION}
fi
else
echo "not deploying on java version: " ${MY_JAVA_VERSION}
echo "not building and maven publishing project as it is a release version: " ${MY_JAVA_VERSION}
fi
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Prepare Release

on:
workflow_dispatch:
branches: ["master"]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Set up Python 2.7
uses: actions/setup-python@v2
with:
python-version: 2.7
- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8
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: Run prepare release script
id: prepare-release
run: |
export MY_POM_VERSION=`./mvnw -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
. ./CI/prepare-release.sh
echo "::set-env name=PREPARE_RELEASE_OK::yes"
else
echo "not preparing release for release version: " ${MY_POM_VERSION}
echo "::set-env name=PREPARE_RELEASE_OK::no"
fi
echo "::set-env name=SC_VERSION::$SC_VERSION"
echo "::set-env name=SC_NEXT_VERSION::$SC_NEXT_VERSION"
- name: Create Prepare Release Pull Request
uses: peter-evans/create-pull-request@v2
if: env.PREPARE_RELEASE_OK == 'yes'
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: prepare release ${{ env.SC_VERSION }}
title: 'prepare release ${{ env.SC_VERSION }}'
branch: prepare-release-${{ env.SC_VERSION }}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SC_VERSION:
SC_NEXT_VERSION:

155 changes: 155 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Release

on:
workflow_dispatch:
branches: ["master"]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Set up Python 2.7
uses: actions/setup-python@v2
with:
python-version: 2.7
- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8
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: Set up Gradle credentials
run: |
mkdir -p ~/.gradle
echo "gradle.publish.key=$GRADLE_PUBLISH_KEY\ngradle.publish.secret=$GRADLE_PUBLISH_SECRET" > ~/.gradle/gradle.properties
- name: Run pre release script
id: preRelease
run: |
# export GPG_TTY=$(tty)
export MY_POM_VERSION=`./mvnw -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
echo "not releasing snapshot version: " ${MY_POM_VERSION}
echo "::set-env name=RELEASE_OK::no"
else
. ./CI/pre-release.sh
echo "::set-env name=RELEASE_OK::yes"
fi
echo "::set-env name=SC_VERSION::$SC_VERSION"
echo "::set-env name=SC_NEXT_VERSION::$SC_NEXT_VERSION"
echo "::set-env name=SC_LAST_RELEASE::$SC_LAST_RELEASE"
- name: configure git user email
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git config --global hub.protocol https
git remote set-url origin https://\${{ secrets.GITHUB_TOKEN }}:x-oauth-basic@github.com/''' + 'swagger-api/swagger-core' + '''.git
- name: Run maven deploy/release (action-maven-publish)
uses: samuelmeuli/action-maven-publish@v1
if: env.RELEASE_OK == 'yes'
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_TOKEN }}
maven_profiles: "release"
- name: Run prepare javadocs script
id: prepareJavadocs
if: env.RELEASE_OK == 'yes'
run: |
. ./CI/prepare-javadocs.sh
- name: Checkout gh-pages
uses: actions/checkout@v2
with:
ref: "gh-pages"
fetch-depth: 0
- name: Run publish javadocs script
id: publishJavadocs
if: env.RELEASE_OK == 'yes'
run: |
TMPDIR="$(dirname -- "${0}")"
. $TMPDIR/publish-javadocs.sh
- name: Checkout master
uses: actions/checkout@v2
with:
ref: "master"
fetch-depth: 0
- name: Run post release script
id: postRelease
if: env.RELEASE_OK == 'yes'
run: |
. ./CI/post-release.sh
- name: Create Next Snapshot Pull Request
uses: peter-evans/create-pull-request@v2
if: env.RELEASE_OK == 'yes'
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: bump snapshot ${{ env.SC_NEXT_VERSION }}-SNAPSHOT
title: 'bump snapshot ${{ env.SC_NEXT_VERSION }}-SNAPSHOT'
branch: bump-snap-${{ env.SC_NEXT_VERSION }}-SNAPSHOT
- name: Checkout 1.5
uses: actions/checkout@v2
with:
ref: "1.5"
fetch-depth: 0
- name: updateV1Readme script
id: updateV1Readme
if: env.RELEASE_OK == 'yes'
run: |
TMPDIR="$(dirname -- "${0}")"
. $TMPDIR/update-v1-readme.sh ${{ env.SC_VERSION }} ${{ env.SC_NEXT_VERSION }}
- name: Create Update V1 Readme Pull Request
uses: peter-evans/create-pull-request@v2
if: env.RELEASE_OK == 'yes'
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: update 1.5 Readme with new v2 version ${{ env.SC_VERSION }}
title: 'update 1.5 Readme with new v2 version ${{ env.SC_VERSION }}'
branch: update-v1-readme-${{ env.SC_VERSION }}
- name: Checkout Wiki
uses: actions/checkout@v2
with:
repository: swagger-api/swagger-core.wiki
token: ${{ steps.generate-token.outputs.token }}
path: wiki
ref: "master"
fetch-depth: 0

- name: Run update wiki script
id: updateWiki
if: env.RELEASE_OK == 'yes'
run: |
TMPDIR="$(dirname -- "${0}")"
. $TMPDIR/update-wiki.sh
- name: Checkout master
uses: actions/checkout@v2
with:
ref: "master"
fetch-depth: 0

env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SC_VERSION:
SC_NEXT_VERSION:
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ atlassian-ide-plugin.xml
*.iml
.java-version
sonar-project.properties
test-output/
test-output/
*.pyc
3 changes: 2 additions & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar
:q

0 comments on commit a3d368b

Please sign in to comment.