未验证 提交 8e1bfbb3 编写于 作者: B Bogdan Kobylynskyi 提交者: GitHub

Automate release process #562 (#567)

* Create scripts for updating project version #562

* Create a new release pipeline #562

* Install GPG secret key, fix maven release step

* Fix maven plugin release configuration

* Fix Gradle plugin signing in release workflow

* Update release workflow

* Revert back versions

* Add a new "update-version" job

* Add inoput parameters to publish specific components
上级 a4c554ab
---
name: Bug Report
about: Create a report to help us improve graphql-java-codegen
title: "[Short Description] (Version: [graphql-java-codegen version])"
title: "[Short Description]"
labels: bug
assignees: ''
......@@ -22,9 +22,8 @@ assignees: ''
## Your Environment and Setup
* **graphql-java-codegen**: *E.g.: 4.1.3*
* **Build tool**: *E.g.: Maven*
* **Java tool**: *E.g.: Oracle 8u241*
* **graphql-java-codegen version**: *X.X.X*
* **Build tool**: *E.g.: Maven/Gradle/SBT*
* **Mapping Config**: *E.g.:*
```xml
......@@ -33,6 +32,3 @@ assignees: ''
<packageName>io.github.kobylynskyi.graphql.model</packageName>
</configuration>
```
## Additional context
Add any other context about the problem here.
......@@ -15,6 +15,3 @@ A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
name: Build
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version'
default: 'X.X.X'
required: true
release_branch:
description: 'Release branch'
default: 'master'
required: true
publish_library:
description: 'Publish library'
default: 'true'
required: true
publish_gradle_plugin:
description: 'Publish Gradle Plugin'
default: 'true'
required: true
publish_maven_plugin:
description: 'Publish Maven Plugin'
default: 'true'
required: true
publish_sbt_plugin:
description: 'Publish SBT Plugin'
default: 'true'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.release_branch }}
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Gradle cache
uses: actions/cache@v1
with:
path: ~/.gradle
key: gradle
- name: Maven cache
uses: actions/cache@v1
with:
path: ~/.m2
key: m2
- name: Loading ivy cache
uses: actions/cache@v1
with:
path: ~/.ivy2/cache
key: ${{ runner.os }}-ivy-${{ hashFiles('**/*.sbt') }}
restore-keys: |
${{ runner.os }}-ivy-
- name: Update version of Maven plugin sub-project
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}" -DgenerateBackupPoms=false
- name: Update version of Maven example client sub-project
working-directory: plugins/maven/example-client
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}" -DgenerateBackupPoms=false
- name: Update version of Maven example server sub-project
working-directory: plugins/maven/example-server
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}" -DgenerateBackupPoms=false
- name: Update versions of all Gradle/SBT sub-projects
run: scripts/update-release-version-in-build-files.sh ${{ github.event.inputs.release_version }}
- name: Update versions in all README files
run: scripts/update-release-version-in-readme.sh ${{ github.event.inputs.release_version }}
#
# VERSIONS ARE IN THE RELEASE STATE, SO WE CAN COMMIT THEM
#
- name: Commit release version so that iw will be pus
run: |
git config --global user.name 'Bogdan Kobylynskyi'
git config --global user.email 'kobylynskyi@users.noreply.github.com'
git commit -am "Bump version to ${{ github.event.inputs.release_version }}"
#
# VERSIONS UPDATED
# NOW WE ARE READY FOR THE FINAL BUILD
#
- name: Build library
run: ./gradlew build publishToMavenLocal publishAllPublicationsToIvyRepository --warning-mode all
- name: Build gradle plugin
run: ./gradlew -p plugins/gradle/graphql-java-codegen-gradle-plugin build publishToMavenLocal --warning-mode all
- name: Update version of Maven plugin to SNAPSHOT (required by publish-plugin)
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}-SNAPSHOT" -DgenerateBackupPoms=false
- name: Build maven plugin
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn install
- name: Build sbt plugin
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt compile publishLocal --debug
- name: Build sbt test
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt scripted
- name: Build gradle example-server --warning-mode all
run: ./gradlew -p plugins/gradle/example-server test --warning-mode all
- name: Build gradle example-client
run: ./gradlew -p plugins/gradle/example-client test --warning-mode all
- name: Build gradle example-client-kotlin
run: ./gradlew -p plugins/gradle/example-client-kotlin build --warning-mode all
- name: Build maven example-server
working-directory: plugins/maven/example-server
run: mvn package
- name: Build maven example-client
working-directory: plugins/maven/example-client
run: mvn package
- name: Install gpg secret key
run: cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
#
# BUILD OF RELEASE VERSION COMPLETED
# NOW PERFORMING THE PUBLISH
#
- name: Release library
if: ${{ github.event.inputs.publish_library }} == "true"
run: |
./gradlew publish \
-Dorg.gradle.internal.publish.checksums.insecure=true \
-Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY}} \
-Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
- name: Release Gradle plugin
if: ${{ github.event.inputs.publish_gradle_plugin }} == "true"
run: |
./gradlew \
-p plugins/gradle/graphql-java-codegen-gradle-plugin \
publishPlugins \
-Dorg.gradle.internal.publish.checksums.insecure=true \
-Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY}} \
-Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
env:
SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
- name: Release Maven plugin
if: ${{ github.event.inputs.publish_maven_plugin }} == "true"
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: |
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
release:clean release:prepare release:perform
- name: Release SBT plugin
if: ${{ github.event.inputs.publish_sbt_plugin }} == "true"
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt release with-defaults default-tag-exists-answer k
#
# PUBLISH OF RELEASE VERSION COMPLETED
# NOW PUSHING THE RELEASE VERSION BACK TO THE REPOSITORY
#
- name: Push release version
run: git push --tags
\ No newline at end of file
name: Build
on:
workflow_dispatch:
inputs:
new_version:
description: 'New version'
required: true
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Update version of Maven plugin sub-project
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn versions:set -DnewVersion="${{ github.event.inputs.new_version }}" -DgenerateBackupPoms=false
- name: Update version of Maven example client sub-project
working-directory: plugins/maven/example-client
run: mvn versions:set -DnewVersion="${{ github.event.inputs.new_version }}" -DgenerateBackupPoms=false
- name: Update version of Maven example server sub-project
working-directory: plugins/maven/example-server
run: mvn versions:set -DnewVersion="${{ github.event.inputs.new_version }}" -DgenerateBackupPoms=false
- name: Update versions of all Gradle/SBT sub-projects
run: scripts/update-release-version-in-build-files.sh ${{ github.event.inputs.new_version }}
- name: Commit and push a new version
run: |
git config --global user.name 'Bogdan Kobylynskyi'
git config --global user.email 'kobylynskyi@users.noreply.github.com'
git commit -am "Bump version to ${{ github.event.inputs.new_version }}"
git push --tags
......@@ -9,8 +9,10 @@ plugins {
id "org.sonarqube" version "3.1.1"
}
version = "4.1.4-SNAPSHOT"
def graphqlCodegenVersion = '4.1.4-SNAPSHOT' // This variable used in the automatic release process
group = "io.github.kobylynskyi"
version = graphqlCodegenVersion
repositories {
mavenCentral()
......
......@@ -7,8 +7,10 @@ plugins {
id "io.github.kobylynskyi.graphql.codegen" version "4.1.4-SNAPSHOT"
}
group 'io.github.dreamylost'
version '4.1.4-SNAPSHOT'
def graphqlCodegenClientKotlinVersion = '4.1.4-SNAPSHOT' // Variable used in the automatic release process
group = 'io.github.dreamylost'
version = graphqlCodegenClientKotlinVersion
sourceCompatibility = 1.8
......
......@@ -16,8 +16,10 @@ apply plugin: "java"
apply plugin: "idea"
apply plugin: "maven-publish"
def graphqlCodegenGradlePluginVersion = '4.1.4-SNAPSHOT' // This variable used in the automatic release process
group = "io.github.kobylynskyi"
version = "4.1.4-SNAPSHOT"
version = graphqlCodegenGradlePluginVersion
description = "Provides a task for generating Java code based on GraphQL schema"
dependencies {
......
......@@ -3,8 +3,8 @@
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-codegen-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>4.1.4-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>graphql-codegen-maven-plugin</name>
<description>Provides a goal for generating Java code based on GraphQL schema</description>
......@@ -36,7 +36,6 @@
<developerConnection>scm:git:git@github.com:kobylynskyi/graphql-java-codegen.git
</developerConnection>
<url>https://github.com/kobylynskyi/graphql-java-codegen/tree/master/plugins/maven</url>
<tag>v4.1.3</tag>
</scm>
<distributionManagement>
......@@ -67,10 +66,9 @@
<version.maven-deploy-plugin>3.0.0-M1</version.maven-deploy-plugin>
<version.nexus-staging-maven-plugin>1.6.8</version.nexus-staging-maven-plugin>
<version.maven-release-plugin>2.5.3</version.maven-release-plugin>
<version.maven-build-helper-plugin>3.2.0</version.maven-build-helper-plugin>
<version.maven-scm-provider-gitexe>1.11.2</version.maven-scm-provider-gitexe>
<version.maven-gpg-plugin>1.6</version.maven-gpg-plugin>
<version.graphql-java-codegen>4.1.4-SNAPSHOT</version.graphql-java-codegen>
</properties>
<dependencies>
......@@ -105,7 +103,7 @@
<dependency>
<groupId>io.github.kobylynskyi</groupId>
<artifactId>graphql-java-codegen</artifactId>
<version>${version.graphql-java-codegen}</version>
<version>${project.version}</version>
</dependency>
</dependencies>
......@@ -220,6 +218,34 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${version.maven-build-helper-plugin}</version>
<executions>
<execution>
<id>parse-versions-for-release</id>
<phase>initialize</phase>
<goals>
<goal>parse-version</goal>
</goals>
<configuration>
<propertyPrefix>parsedVersion</propertyPrefix>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${version.maven-release-plugin}</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<!--suppress UnresolvedMavenProperty -->
<developmentVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.patchVersion}</developmentVersion>
<dryRun>true</dryRun>
</configuration>
</plugin>
</plugins>
</build>
......@@ -247,6 +273,12 @@
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
......
......@@ -21,8 +21,6 @@ graphqlJavaCodegenVersion := Some((version in Scope.ThisScope).value)
GraphQLCodegenPluginDependencies
//default graphqlJavaCodegen is release
//graphqlJavaCodegenVersion := Some("4.1.4-SNAPSHOT")
graphqlSchemaPaths := List("src/main/resources/schema.graphqls")
modelPackageName := Some("io.github.dreamylost.model")
apiPackageName := Some("io.github.dreamylost.api")
......
#!/bin/bash
RELEASE_VERSION=$1
RELEASE_VERSION_ESCAPED=${RELEASE_VERSION//./\\.}
set_version_in_file() {
sed -i '' "s/$2[A-Z0-9.\-]*/$2$RELEASE_VERSION_ESCAPED/" "$1"
echo "Updated version in $1"
}
set_version_in_file "build.gradle" "var graphqlCodegenVersion = '"
set_version_in_file "plugins/gradle/graphql-java-codegen-gradle-plugin/build.gradle" "var graphqlCodegenGradlePluginVersion = '"
set_version_in_file "plugins/gradle/example-server/build.gradle" "io.github.kobylynskyi.graphql.codegen\" version \""
set_version_in_file "plugins/gradle/example-client/build.gradle" "implementation \"io.github.kobylynskyi:graphql-java-codegen:"
set_version_in_file "plugins/gradle/example-client/build.gradle" "io.github.kobylynskyi.graphql.codegen\" version \""
set_version_in_file "plugins/gradle/example-client-kotlin/build.gradle" "id \"io.github.kobylynskyi.graphql.codegen\" version \""
set_version_in_file "plugins/gradle/example-client-kotlin/build.gradle" "var graphqlCodegenClientKotlinVersion = '"
set_version_in_file "plugins/gradle/example-client-kotlin/build.gradle" "implementation \"io.github.kobylynskyi:graphql-java-codegen:"
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/version.sbt" "version in ThisBuild := \""
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/version.sbt" "version in ThisBuild := \""
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client/project/plugins.sbt" "graphql-codegen-sbt-plugin\" % \""
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/version.sbt" "version in ThisBuild := \""
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/example-client-scala/project/plugins.sbt" "graphql-codegen-sbt-plugin\" % \""
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/version.sbt" "version in ThisBuild := \""
set_version_in_file "plugins/sbt/graphql-java-codegen-sbt-plugin/src/sbt-test/graphql-codegen-sbt-plugin/simple/project/plugins.sbt" "plugin.version\").orElse(Some(\""
# Exit clean
exit 0
#!/bin/bash
RELEASE_VERSION=$1
RELEASE_VERSION_ESCAPED=${RELEASE_VERSION//./\\.}
set_version_in_file() {
sed -i '' "s/$2[A-Z0-9.\-]*/$2$RELEASE_VERSION_ESCAPED/" "$1"
echo "Updated version in $1"
}
set_version_in_file "plugins/gradle/README.md" "id \"io.github.kobylynskyi.graphql.codegen\" version \""
set_version_in_file "plugins/gradle/README.md" "io.github.kobylynskyi.graphql.codegen:graphql-codegen-gradle-plugin:"
set_version_in_file "plugins/maven/README.md" "<version>"
# Exit clean
exit 0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册