Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #564 from eclipse/infra/ci-rework
Browse files Browse the repository at this point in the history
Automated deployment
  • Loading branch information
jponge authored Oct 26, 2020
2 parents a8d897d + ea35b71 commit e3e4934
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 20 deletions.
23 changes: 22 additions & 1 deletion .build/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
set -euo pipefail
IFS=$'\n\t'

function cleanup {
echo "🧹 Cleanup..."
rm -f gradle.properties golo-dev-sign.asc
}

trap cleanup SIGINT SIGTERM ERR EXIT

echo "🚀 Preparing to deploy..."

echo "✅ Done"
echo "🔑 Decrypting files..."

gpg --quiet --batch --yes --decrypt --passphrase="${GPG_SECRET}" \
--output golo-dev-sign.asc .build/golo-dev-sign.asc.gpg

gpg --quiet --batch --yes --decrypt --passphrase="${GPG_SECRET}" \
--output gradle.properties .build/gradle.properties.gpg

gpg --fast-import --no-tty --batch --yes golo-dev-sign.asc

echo "📦 Publishing..."

./gradlew publish

echo "✅ Done!"
Binary file added .build/golo-dev-sign.asc.gpg
Binary file not shown.
Binary file added .build/gradle.properties.gpg
Binary file not shown.
36 changes: 34 additions & 2 deletions .github/workflows/continuous-integration-and-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- master
tags:
- 'milestone/*'
- 'release/*'
pull_request:
branches:
- master
Expand Down Expand Up @@ -34,13 +37,42 @@ jobs:
- name: Build with Gradle
run: ./gradlew build

- name: Upload build distribution
- name: Copy build distribution
run: cp build/distributions/*.zip golo-distribution.zip

- name: Attach build distribution from this build
uses: actions/upload-artifact@v2
with:
name: Golo distribution from this build
path: build/distributions/*.zip
path: ./golo-distribution.zip

# Only pushes to master trigger a publication to Sonatype OSS
- name: Deploy
if: github.ref == 'refs/heads/master'
run: .build/deploy.sh
env:
GPG_SECRET: ${{ secrets.GPG_SECRET }}

# Only pushes of tags trigger a release creation
- name: Create the release
id: create_release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: startsWith(github.ref, 'refs/tags/milestone/')
- name: Attach build distribution to the release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./golo-distribution.zip
asset_name: golo-distribution.zip
asset_content_type: application/zip

20 changes: 4 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ val goloClasses = "$buildDir/golo-classes"
val goloDocs = file("$buildDir/docs/golodoc")

val isReleaseVersion = !version.toString().endsWith("SNAPSHOT")
val isCalledFromCI = "true" == System.getenv("CI")

dependencies {
implementation("org.ow2.asm:asm:8.0")
Expand Down Expand Up @@ -349,8 +348,8 @@ publishing {
maven {
name = "SonatypeOSS"
credentials {
username = if (project.hasProperty("ossrhUsername")) (project.property("ossrhUsername") as String) else (System.getenv("OSSRH_USERNAME") ?: "N/A")
password = if (project.hasProperty("ossrhPassword")) (project.property("ossrhPassword") as String) else (System.getenv("OSSRH_PASSWORD") ?: "N/A")
username = if (project.hasProperty("ossrhUsername")) (project.property("ossrhUsername") as String) else "N/A"
password = if (project.hasProperty("ossrhPassword")) (project.property("ossrhPassword") as String) else "N/A"
}
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
Expand All @@ -360,23 +359,12 @@ publishing {
}
}
tasks.withType<PublishToMavenRepository> {
onlyIf {
!isCalledFromCI || (isCalledFromCI && !isReleaseVersion)
}
}
signing {
useGpgCmd()
sign(publishing.publications["main"])
}
tasks.withType<Sign>().configureEach {
onlyIf {
isReleaseVersion
}
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "6.6.1"
gradleVersion = "6.7"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit e3e4934

Please sign in to comment.