Skip to content

Commit 5a55742

Browse files
authored
Merge pull request #3667 from swagger-api/gradle-ga
Automation - fix gradle publishing
2 parents 88ad2dd + d64dd8f commit 5a55742

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

.github/workflows/post-release.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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: Set up Gradle credentials
38+
run: |
39+
mkdir -p ~/.gradle
40+
echo "gradle.publish.key=${GRADLE_PUBLISH_KEY}\ngradle.publish.secret=${GRADLE_PUBLISH_SECRET}" > ~/.gradle/gradle.properties
41+
- name: Run pre release script
42+
id: preRelease
43+
run: |
44+
# export GPG_TTY=$(tty)
45+
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`
46+
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
47+
then
48+
echo "not releasing snapshot version: " ${MY_POM_VERSION}
49+
echo "::set-env name=RELEASE_OK::no"
50+
else
51+
. ./CI/pre-release.sh
52+
echo "::set-env name=RELEASE_OK::yes"
53+
fi
54+
echo "::set-env name=SC_VERSION::$SC_VERSION"
55+
echo "::set-env name=SC_NEXT_VERSION::$SC_NEXT_VERSION"
56+
echo "::set-env name=SC_LAST_RELEASE::$SC_LAST_RELEASE"
57+
- name: configure git user email
58+
run: |
59+
git config --global user.email "[email protected]"
60+
git config --global user.name "GitHub Action"
61+
git config --global hub.protocol https
62+
git remote set-url origin https://\${{ secrets.GITHUB_TOKEN }}:[email protected]/''' + 'swagger-api/swagger-core' + '''.git
63+
- name: Checkout master
64+
uses: actions/checkout@v2
65+
with:
66+
ref: "master"
67+
fetch-depth: 0
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+
- name: Checkout 1.5
82+
uses: actions/checkout@v2
83+
with:
84+
ref: "1.5"
85+
fetch-depth: 0
86+
- name: updateV1Readme script
87+
id: updateV1Readme
88+
if: env.RELEASE_OK == 'yes'
89+
run: |
90+
TMPDIR="$(dirname -- "${0}")"
91+
. $TMPDIR/update-v1-readme.sh ${{ env.SC_VERSION }} ${{ env.SC_NEXT_VERSION }}
92+
- name: Create Update V1 Readme Pull Request
93+
uses: peter-evans/create-pull-request@v2
94+
if: env.RELEASE_OK == 'yes'
95+
with:
96+
token: ${{ steps.generate-token.outputs.token }}
97+
commit-message: update 1.5 Readme with new v2 version ${{ env.SC_VERSION }}
98+
title: 'update 1.5 Readme with new v2 version ${{ env.SC_VERSION }}'
99+
branch: update-v1-readme-${{ env.SC_VERSION }}
100+
- name: Checkout Wiki
101+
uses: actions/checkout@v2
102+
with:
103+
repository: swagger-api/swagger-core.wiki
104+
token: ${{ steps.generate-token.outputs.token }}
105+
path: wiki
106+
ref: "master"
107+
fetch-depth: 0
108+
109+
- name: Run update wiki script
110+
id: updateWiki
111+
if: env.RELEASE_OK == 'yes'
112+
run: |
113+
TMPDIR="$(dirname -- "${0}")"
114+
. $TMPDIR/update-wiki.sh
115+
- name: Checkout master
116+
uses: actions/checkout@v2
117+
with:
118+
ref: "master"
119+
fetch-depth: 0
120+
121+
env:
122+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
123+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
124+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125+
SC_VERSION:
126+
SC_NEXT_VERSION:
127+
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
128+
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}
129+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
130+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Set up Gradle credentials
3838
run: |
3939
mkdir -p ~/.gradle
40-
echo "gradle.publish.key=$GRADLE_PUBLISH_KEY\ngradle.publish.secret=$GRADLE_PUBLISH_SECRET" > ~/.gradle/gradle.properties
40+
echo "gradle.publish.key=${GRADLE_PUBLISH_KEY}\ngradle.publish.secret=${GRADLE_PUBLISH_SECRET}" > ~/.gradle/gradle.properties
4141
- name: Run pre release script
4242
id: preRelease
4343
run: |

CI/post-release.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ SC_RELEASE_TAG="v$SC_VERSION"
99
### deploy gradle plugin release
1010
#####################
1111
cd modules/swagger-gradle-plugin
12-
./gradlew publishPlugins --info
12+
echo "GRADLE_PUBLISH_KEY len: "
13+
echo -n $GRADLE_PUBLISH_KEY | wc -m;
14+
echo "GRADLE_PUBLISH_SECRET len: "
15+
echo -n $GRADLE_PUBLISH_SECRET | wc -m;
16+
./gradlew publishPlugins -Pgradle.publish.key="${GRADLE_PUBLISH_KEY}" -Pgradle.publish.secret="${GRADLE_PUBLISH_SECRET}" --info
1317
cd ../..
1418

1519
#####################

0 commit comments

Comments
 (0)