Skip to content

Commit 1e11d15

Browse files
committed
add GH actions for build and release automation
1 parent 03b88d9 commit 1e11d15

17 files changed

+769
-0
lines changed

.github/topissuebot.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
labelName: ":thumbsup: Top Issue!"
2+
labelColor: "f442c2"
3+
numberOfIssuesToLabel: 5

.github/workflows/codeql-analysis.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Code scanning - action"
2+
3+
on:
4+
push:
5+
branches: [master, v1]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [master, v1]
9+
schedule:
10+
- cron: '0 19 * * 1'
11+
12+
jobs:
13+
CodeQL-Build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
with:
21+
# We must fetch at least the immediate parents so that if this is
22+
# a pull request then we can checkout the head.
23+
fetch-depth: 2
24+
25+
# If this run was triggered by a pull request event, then checkout
26+
# the head of the pull request instead of the merge commit.
27+
- run: git checkout HEAD^2
28+
if: ${{ github.event_name == 'pull_request' }}
29+
30+
# Initializes the CodeQL tools for scanning.
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@v1
33+
# Override language selection by uncommenting this and choosing your languages
34+
with:
35+
languages: java
36+
37+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
38+
# If this step fails, then you should remove it and run the build manually (see below)
39+
- name: Autobuild
40+
uses: github/codeql-action/autobuild@v1
41+
42+
# ℹ️ Command-line programs to run using the OS shell.
43+
# 📚 https://git.io/JvXDl
44+
45+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
46+
# and modify them (or add more) to build your code if your project
47+
# uses a compiled language
48+
49+
#- run: |
50+
# make bootstrap
51+
# make release
52+
53+
- name: Perform CodeQL Analysis
54+
uses: github/codeql-action/analyze@v1

.github/workflows/maven-pulls.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build Test PR
2+
3+
on:
4+
pull_request:
5+
branches: [ "master" ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
java: [ 8, 11, 14 ]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Java
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: ${{ matrix.java }}
21+
- name: Cache local Maven repository
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.m2/repository
25+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
26+
restore-keys: |
27+
${{ runner.os }}-maven-
28+
- name: Build with Maven
29+
run: |
30+
mvn --no-transfer-progress -B install --file pom.xml

.github/workflows/maven-v1-pulls.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build Test PR v1
2+
3+
on:
4+
pull_request:
5+
branches: [ "v1" ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
java: [ 8 ]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Java
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: ${{ matrix.java }}
21+
- name: Cache local Maven repository
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.m2/repository
25+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
26+
restore-keys: |
27+
${{ runner.os }}-maven-
28+
- name: Build with Maven
29+
run: mvn -B -Dhttps.protocols=TLSv1.2 verify --file pom.xml

.github/workflows/maven-v1.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build Test Deploy v1
2+
3+
on:
4+
push:
5+
branches: [ "v1" ]
6+
pull_request:
7+
branches: [ "v1" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
java: [ 8 ]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Java
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: ${{ matrix.java }}
23+
server-id: sonatype-nexus-snapshots
24+
server-username: MAVEN_USERNAME
25+
server-password: MAVEN_PASSWORD
26+
- name: Cache local Maven repository
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.m2/repository
30+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: |
32+
${{ runner.os }}-maven-
33+
- name: Build with Maven
34+
run: |
35+
mvn -B -Dhttps.protocols=TLSv1.2 verify --file pom.xml
36+
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`
37+
echo "POM VERSION" ${MY_POM_VERSION}
38+
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
39+
then
40+
mvn -B -Dhttps.protocols=TLSv1.2 clean deploy
41+
else
42+
echo "not deploying release: " ${MY_POM_VERSION}
43+
fi
44+
env:
45+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
46+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

.github/workflows/maven.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build Test Deploy master
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
java: [ 8, 11, 14 ]
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Java
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: ${{ matrix.java }}
21+
server-id: ossrh
22+
server-username: MAVEN_USERNAME
23+
server-password: MAVEN_PASSWORD
24+
- name: Cache local Maven repository
25+
uses: actions/cache@v2
26+
with:
27+
path: ~/.m2/repository
28+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
29+
restore-keys: |
30+
${{ runner.os }}-maven-
31+
- name: Build with Maven, Deploy snapshot to maven central
32+
run: |
33+
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`
34+
echo "POM VERSION" ${MY_POM_VERSION}
35+
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
36+
then
37+
mvn --no-transfer-progress -B install --file pom.xml
38+
export MY_JAVA_VERSION=`java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
39+
echo "JAVA VERSION" ${MY_JAVA_VERSION}
40+
if [[ ${MY_JAVA_VERSION} == "8" ]];
41+
then
42+
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`
43+
echo "POM VERSION" ${MY_POM_VERSION}
44+
mvn --no-transfer-progress -B clean deploy
45+
else
46+
echo "not deploying on java version: " ${MY_JAVA_VERSION}
47+
fi
48+
else
49+
echo "not building and maven publishing project as it is a release version: " ${MY_JAVA_VERSION}
50+
fi
51+
env:
52+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
53+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

.github/workflows/prepare-release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
branches: ["master"]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: tibdex/github-app-token@v1
15+
id: generate-token
16+
with:
17+
app_id: ${{ secrets.APP_ID }}
18+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
19+
- name: Set up Python 2.7
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 2.7
23+
- name: Set up Java 8
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: 8
27+
server-id: ossrh
28+
server-username: MAVEN_USERNAME
29+
server-password: MAVEN_PASSWORD
30+
- name: Cache local Maven repository
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/.m2/repository
34+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: |
36+
${{ runner.os }}-maven-
37+
- name: Run prepare release script
38+
id: prepare-release
39+
run: |
40+
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`
41+
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
42+
then
43+
. ./CI/prepare-release.sh
44+
echo "::set-env name=PREPARE_RELEASE_OK::yes"
45+
else
46+
echo "not preparing release for release version: " ${MY_POM_VERSION}
47+
echo "::set-env name=PREPARE_RELEASE_OK::no"
48+
fi
49+
echo "::set-env name=SC_VERSION::$SC_VERSION"
50+
echo "::set-env name=SC_NEXT_VERSION::$SC_NEXT_VERSION"
51+
- name: Create Prepare Release Pull Request
52+
uses: peter-evans/create-pull-request@v2
53+
if: env.PREPARE_RELEASE_OK == 'yes'
54+
with:
55+
token: ${{ steps.generate-token.outputs.token }}
56+
commit-message: prepare release ${{ env.SC_VERSION }}
57+
title: 'prepare release ${{ env.SC_VERSION }}'
58+
branch: prepare-release-${{ env.SC_VERSION }}
59+
env:
60+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
61+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
SC_VERSION:
64+
SC_NEXT_VERSION:
65+

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
branches: ["master"]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: tibdex/github-app-token@v1
15+
id: generate-token
16+
with:
17+
app_id: ${{ secrets.APP_ID }}
18+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
19+
- name: Set up Python 2.7
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 2.7
23+
- name: Set up Java 8
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: 8
27+
server-id: ossrh
28+
server-username: MAVEN_USERNAME
29+
server-password: MAVEN_PASSWORD
30+
- name: Cache local Maven repository
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/.m2/repository
34+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: |
36+
${{ runner.os }}-maven-
37+
- name: Run pre release script
38+
id: preRelease
39+
run: |
40+
# export GPG_TTY=$(tty)
41+
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`
42+
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
43+
then
44+
echo "not releasing snapshot version: " ${MY_POM_VERSION}
45+
echo "::set-env name=RELEASE_OK::no"
46+
else
47+
. ./CI/pre-release.sh
48+
echo "::set-env name=RELEASE_OK::yes"
49+
fi
50+
echo "::set-env name=SC_VERSION::$SC_VERSION"
51+
echo "::set-env name=SC_NEXT_VERSION::$SC_NEXT_VERSION"
52+
echo "::set-env name=SC_LAST_RELEASE::$SC_LAST_RELEASE"
53+
- name: configure git user email
54+
run: |
55+
git config --global user.email "action@github.com"
56+
git config --global user.name "GitHub Action"
57+
git config --global hub.protocol https
58+
git remote set-url origin https://\${{ secrets.GITHUB_TOKEN }}:x-oauth-basic@github.com/''' + 'swagger-api/swagger-parser' + '''.git
59+
- name: Run maven deploy/release (action-maven-publish)
60+
uses: samuelmeuli/action-maven-publish@v1
61+
if: env.RELEASE_OK == 'yes'
62+
with:
63+
gpg_private_key: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
64+
gpg_passphrase: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}
65+
nexus_username: ${{ secrets.OSSRH_USERNAME }}
66+
nexus_password: ${{ secrets.OSSRH_TOKEN }}
67+
maven_profiles: "release"
68+
- name: Run post release script
69+
id: postRelease
70+
if: env.RELEASE_OK == 'yes'
71+
run: |
72+
. ./CI/post-release.sh
73+
- name: Create Next Snapshot Pull Request
74+
uses: peter-evans/create-pull-request@v2
75+
if: env.RELEASE_OK == 'yes'
76+
with:
77+
token: ${{ steps.generate-token.outputs.token }}
78+
commit-message: bump snapshot ${{ env.SC_NEXT_VERSION }}-SNAPSHOT
79+
title: 'bump snapshot ${{ env.SC_NEXT_VERSION }}-SNAPSHOT'
80+
branch: bump-snap-${{ env.SC_NEXT_VERSION }}-SNAPSHOT
81+
82+
env:
83+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
84+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
85+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
SC_VERSION:
87+
SC_NEXT_VERSION:
88+
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
89+
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}

0 commit comments

Comments
 (0)