Skip to content

Commit b7717b1

Browse files
committed
Added release workflow
1 parent 3fa6e15 commit b7717b1

File tree

4 files changed

+109
-27
lines changed

4 files changed

+109
-27
lines changed

.github/workflows/build.yml

+22-24
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ on:
44
push:
55
branches:
66
- '**'
7-
tags-ignore:
8-
- '**'
97
paths-ignore:
10-
- '.github/publish.yml'
8+
- '.github/workflows/publish.yml'
9+
- '.github/workflows/release.yml'
1110
- 'example/**'
1211
- '.gitignore'
1312
- 'LICENSE'
1413
- 'README.md'
1514
pull_request:
1615
branches:
1716
- '**'
18-
tags-ignore:
19-
- '**'
2017
paths-ignore:
21-
- '.github/publish.yml'
18+
- '.github/workflows/publish.yml'
19+
- '.github/workflows/release.yml'
2220
- 'example/**'
2321
- '.gitignore'
2422
- 'LICENSE'
@@ -29,24 +27,24 @@ jobs:
2927
runs-on: ubuntu-latest
3028
steps:
3129

32-
- name: Checkout
33-
uses: actions/checkout@v2
30+
- name: Checkout
31+
uses: actions/checkout@v2
3432

35-
- name: Set up Java
36-
uses: actions/setup-java@v1
37-
with:
38-
java-version: 11
33+
- name: Set up Java
34+
uses: actions/setup-java@v1
35+
with:
36+
java-version: 11
3937

40-
- name: Cache
41-
uses: actions/cache@v2
42-
with:
43-
path: ~/.m2/repository
44-
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
45-
restore-keys: |
46-
${{ runner.os }}-maven-
38+
- name: Cache
39+
uses: actions/cache@v2
40+
with:
41+
path: ~/.m2/repository
42+
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
43+
restore-keys: |
44+
${{ runner.os }}-maven-
4745
48-
- name: Build
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
52-
run: mvn -B -Dmaven.javadoc.skip=true -Dmaven.source.skip=true clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
46+
- name: Build
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
50+
run: mvn -B -Dmaven.javadoc.skip=true -Dmaven.source.skip=true clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

.github/workflows/publish.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ jobs:
3232
run: cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
3333

3434
- name: Build
35-
run: mvn -B clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38+
run: mvn -B -Dmaven.javadoc.skip=true -Dmaven.source.skip=true clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
3639

3740
- name: Publish
38-
run: mvn -B -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} deploy
41+
run: mvn -B -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} -DskipTests clean deploy
3942
env:
4043
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
4144
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

.github/workflows/release.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: 'Release version if different than actual without SNAPSHOT'
8+
default: ''
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Java
19+
uses: actions/setup-java@v1
20+
with:
21+
java-version: 11
22+
23+
- name: Cache
24+
uses: actions/cache@v2
25+
with:
26+
path: ~/.m2/repository
27+
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
28+
restore-keys: |
29+
${{ runner.os }}-maven-
30+
31+
- name: Set up Git
32+
run: |
33+
git config --global user.name "jsonschema2pojo-androidx-databinding"
34+
git config --global user.email "[email protected]"
35+
36+
- name: Update version
37+
if: "github.event.inputs.releaseVersion != ''"
38+
run: |
39+
# Update development version if needed and commit
40+
echo "New development version is ${{ github.event.inputs.releaseVersion }}-SNAPSHOT"
41+
mvn -B versions:set -DnewVersion=${{ github.event.inputs.releaseVersion }}-SNAPSHOT
42+
git commit pom.xml -m "Updated development version to ${{ github.event.inputs.releaseVersion }}-SNAPSHOT"
43+
44+
- name: Tag version
45+
id: tag-version
46+
run: |
47+
# Get current development version
48+
CURRENT_DEV_VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
49+
echo "Current development version is $CURRENT_DEV_VERSION"
50+
# Get release version
51+
RELEASE_VERSION=${CURRENT_DEV_VERSION%-SNAPSHOT}
52+
echo "Release version is $RELEASE_VERSION"
53+
# Update with release version, commit and push
54+
mvn -B versions:set -DnewVersion="${RELEASE_VERSION}"
55+
git commit pom.xml -m "Release ${RELEASE_VERSION}"
56+
git push
57+
# Tag and push
58+
git tag -a v$RELEASE_VERSION -m v$RELEASE_VERSION
59+
git push --follow-tags
60+
echo "::set-output name=releaseVersion::${RELEASE_VERSION}"
61+
echo "::set-output name=tagName::v${RELEASE_VERSION}"
62+
63+
- name: Create release
64+
uses: actions/create-release@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.PAT }}
67+
with:
68+
tag_name: ${{ steps.tag-version.outputs.tagName }}
69+
release_name: ${{ steps.tag-version.outputs.releaseVersion }}
70+
body: "Hosted on [Maven Central](https://search.maven.org/artifact/io.github.hectorbst/jsonschema2pojo-androidx-databinding/${{ steps.tag-version.outputs.releaseVersion }}/jar)."
71+
draft: false
72+
prerelease: false
73+
74+
- name: Increment version
75+
run: |
76+
# Increment to next development version, get it, commit and push
77+
mvn -B org.apache.maven.plugins:maven-release-plugin:update-versions
78+
NEXT_DEV_VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
79+
echo "Next development is $NEXT_DEV_VERSION"
80+
git commit pom.xml -m "Started version ${NEXT_DEV_VERSION}"
81+
git push

example/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ android.enableJetifier=true
44

55
androidGradleVersion=4.0.1
66
jsonschema2pojoVersion=1.0.2
7-
jsonschema2pojoDataBindingVersion=0.0.1
7+
jsonschema2pojoDataBindingVersion=0.1.0

0 commit comments

Comments
 (0)