Skip to content

Commit 3369818

Browse files
authored
Merge pull request #1446 from swagger-api/test-next-snap
automation - next snapshot action
2 parents 651be45 + 9e1766a commit 3369818

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/next-snapshot.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 "[email protected]"
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 }}:[email protected]/''' + 'swagger-api/swagger-parser' + '''.git
59+
- name: Run post release script
60+
id: postRelease
61+
if: env.RELEASE_OK == 'yes'
62+
run: |
63+
. ./CI/post-nextsnap.sh
64+
- name: Create Next Snapshot Pull Request
65+
uses: peter-evans/create-pull-request@v2
66+
if: env.RELEASE_OK == 'yes'
67+
with:
68+
token: ${{ steps.generate-token.outputs.token }}
69+
commit-message: bump snapshot ${{ env.SC_NEXT_VERSION }}-SNAPSHOT
70+
title: 'bump snapshot ${{ env.SC_NEXT_VERSION }}-SNAPSHOT'
71+
branch: bump-snap-${{ env.SC_NEXT_VERSION }}-SNAPSHOT
72+
73+
env:
74+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
75+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
SC_VERSION:
78+
SC_NEXT_VERSION:
79+
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
80+
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PRIVATE_PASSPHRASE }}

CI/post-nextsnap.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
CUR=$(pwd)
4+
TMPDIR="$(dirname -- "${0}")"
5+
6+
SC_RELEASE_TAG="v$SC_VERSION"
7+
8+
#####################
9+
### update the version to next snapshot in maven project with set version
10+
#####################
11+
mvn versions:set -DnewVersion="${SC_NEXT_VERSION}-SNAPSHOT"
12+
mvn versions:commit

0 commit comments

Comments
 (0)