Skip to content

Commit

Permalink
Use GitHub actions
Browse files Browse the repository at this point in the history
Publish on GitHub Releases

Publish to GitHub Packages
  • Loading branch information
sbrunner committed Jan 20, 2020
1 parent dd03c6e commit 8aed4cc
Show file tree
Hide file tree
Showing 19 changed files with 231 additions and 257 deletions.
94 changes: 6 additions & 88 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,16 @@
# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
---
version: 2.1

orbs:
gradle: circleci/gradle@1.0.10

jobs:
build:
docker:
- image: circleci/openjdk:8-jdk

working_directory: ~/repo

environment:
TERM: dumb

machine: true
steps:
- checkout

- run:
command: sudo apt update
- run:
name: Install OS dependencies
command: sudo apt install ttf-liberation

- run: git --no-pager diff --check `git log --oneline | tail -1 | cut --fields=1 --delimiter=' '`

- run: circleci/test-eof-newline

- gradle/with_cache:
steps:
- run:
name: Build
command: ./gradlew build

- store_artifacts:
path: examples/build/reports
destination: reports/examples
- store_artifacts:
path: core/build/reports
destination: reports/core
- store_artifacts:
path: examples/build/resources/test/examples
destination: examples
- run:
name: Collect test results
command: |
mkdir -p /tmp/test_results/junit
find . -name '*TEST-*.xml' -exec cp -v {} /tmp/test_results/junit/ \;
when: always
- store_test_results:
path: /tmp/test_results

- run:
name: Don't publish for PRs from forks
command: '[ -n "$AES_IV" ] && true || circleci step halt'

- run:
name: Decrypt secrets
command: |
set -e
mkdir -p $HOME/.gradle/
openssl aes-256-cbc -K $AES_KEY -iv $AES_IV -in circleci/gradle.properties.enc -out ~/.gradle/gradle.properties -d
openssl aes-256-cbc -K $AES_KEY -iv $AES_IV -in circleci/signing.gpg.enc -d | gpg --import || true
openssl aes-256-cbc -K $AES_KEY -iv $AES_IV -in circleci/signing.gpg.enc -d > ~/.gnupg/secring.gpg
openssl aes-256-cbc -K $AES_KEY -iv $AES_IV -in circleci/dockercfg.enc -out ~/.dockercfg -d
- setup_remote_docker

- run:
name: publish
command: circleci/publish.sh
- run: echo Disabled
workflows:
version: 2
push:
jobs: &jobs
- build

tag_push:
workflow:
jobs:
- build:
filters:
tags:
only: /^release\/\d+\.\d+\.\d+/
branches:
ignore: /.*/

nightly:
triggers:
- schedule:
cron: 0 0 * * *
filters:
branches:
only: /master|3\.\d+/
jobs: *jobs
only:
- none
2 changes: 0 additions & 2 deletions .dockercfg.enc

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
*.jks binary
*.enc binary
*.icc binary
*.gpg binary
153 changes: 153 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: CI

on:
push:
schedule:
- cron: '0 0 * * *'

jobs:
build:
runs-on: ubuntu-18.04
name: CI
env:
SUMMON_PROVIDER: /usr/local/bin/gopass
steps:
- run: echo ${{ github.ref }}

- uses: actions/checkout@v1

- name: Get tag
id: tag2
uses: frabert/replace-string-action@v1.1
with:
pattern: 'refs/tags/(.*)'
string: '{{ github.ref }}'
replace-with: '$1'
if: "startsWith(github.ref, 'refs/tags/')"
- run: echo --${{ steps.tag2.outputs.replaced }}--

- uses: actions/setup-java@v1
with:
java-version: 8.0.232
- run: java -version

- run: sudo apt update
- name: Install OS dependencies
run: sudo apt install fonts-liberation

- run: git --no-pager diff --check `git log --oneline | tail -1 | cut --fields=1 --delimiter=' '`
- run: ci/test-eof-newline

- uses: camptocamp/initialise-gopass-summon-action@v1
with:
large-secret-passphrase: ${{secrets.LARGE_SECRET_PASSPHRASE}}
github-gopass-ci-token: ${{secrets.GITHUB_GOPASS_CI_TOKEN}}
- run: gpg --export-secret-keys --armor D121AF2DFA8E140688BD968930C9B913FD42EF13 > CI.asc

- run: ./gradlew build

- uses: actions/upload-artifact@v1
with:
name: Reports examples
path: examples/build/reports
if: always()
- uses: actions/upload-artifact@v1
with:
name: Reports core
path: core/build/reports
if: always()
- uses: actions/upload-artifact@v1
with:
name: Examples
path: examples/build/resources/test/examples
if: always()

- name: Collect test results
run: |
mkdir -p /tmp/test_results/junit
find . -name '*TEST-*.xml' -exec cp -v {} /tmp/test_results/junit/ \;
if: failure()
- uses: actions/upload-artifact@v1
with:
name: Test results
path: /tmp/test_results
if: failure()

- run: mkdir -p ~/.docker
- name: Decrypt secrets
run: summon --environment dockerhub bash -c 'envsubst < ci/docker-config.json.tmpl > ~/.docker/config.json'

- name: publish
run: ci/publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: ./gradlew :core:libSourcesJar
if: "startsWith(github.ref, 'refs/tags/')"
- run: ./gradlew :core:libJavadocJar
if: "startsWith(github.ref, 'refs/tags/')"
- id: version
run: echo "##[set-output name=version;]$(grep version build.gradle|sed "s/ \+version = .\(.*\)./\1/g")"
- id: tag
run: echo "##[set-output name=tag;]$(echo github.ref|sed 's%refs/tags/%%g')"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
if: "startsWith(github.ref, 'refs/tags/')"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./core/build/libs/print-servlet-${{ steps.version.outputs.version }}.war
asset_name: print-servlet-${{ steps.version.outputs.version }}.war
asset_content_type: application/java-archive
if: "startsWith(github.ref, 'refs/tags/')"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./core/build/distributions/core-${{ steps.version.outputs.version }}.zip
asset_name: print-cli-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip
if: "startsWith(github.ref, 'refs/tags/')"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./core/build/libs/print-lib-${{ steps.version.outputs.version }}.jar
asset_name: print-lib-${{ steps.version.outputs.version }}.jar
asset_content_type: application/java-archive
if: "startsWith(github.ref, 'refs/tags/')"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./core/build/libs/print-lib-${{ steps.version.outputs.version }}-sources.jar
asset_name: print-lib-${{ steps.version.outputs.version }}-sources.jar
asset_content_type: application/java-archive
if: "startsWith(github.ref, 'refs/tags/')"
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./core/build/libs/print-lib-${{ steps.version.outputs.version }}-javadoc.jar
asset_name: print-lib-${{ steps.version.outputs.version }}-javadoc.jar
asset_content_type: application/java-archive
if: "startsWith(github.ref, 'refs/tags/')"
Binary file added CI.asc.gpg
Binary file not shown.
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.. image:: https://circleci.com/gh/mapfish/mapfish-print/tree/master.svg?style=svg
:target: https://circleci.com/gh/mapfish/mapfish-print/tree/master

Please read the documentation available here:
http://mapfish.github.io/mapfish-print/

Expand Down Expand Up @@ -82,6 +79,7 @@ To list all the commandline options then execute (the current direstory is `./co
If you want to run in debug mode you can do the following:

.. code::
> ./gradlew print --debug-jvm -PprintArgs="-config ../examples/src/test/resources/examples/simple/config.yaml -spec ../examples/src/test/resources/examples/simple/requestData.json -output ./output.pdf"
Expand Down
18 changes: 0 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ buildscript {

dependencies {
classpath 'org.gretty:gretty:3.0.1'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.2'
classpath 'de.marcphilipp.gradle:nexus-publish-plugin:0.4.0'
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:2.0.0"
classpath "se.bjurr.violations:violations-gradle-plugin:1.39"
}
Expand All @@ -30,9 +28,6 @@ allprojects {
ext.springVersion = "5.2.3.RELEASE"
ext.groovyVersion = "2.5.9"
ext.spotbugVersion = '3.1.12'
ext."signing.keyId" = signing_keyId
ext."signing.secretKeyRingFile" = System.properties.get('user.home') + '/.gnupg/secring.gpg'
ext."signing.password" = signing_password
}

configurations.all {
Expand All @@ -57,7 +52,6 @@ configure(subprojects.findAll { ['core', 'examples', 'docs'].contains(it.name) }
maven { url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts" }
maven { url "https://repo.boundlessgeo.com/main/" }
maven { url "https://jaspersoft.artifactoryonline.com/jaspersoft/jr-ce-releases" }
maven { url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/" }
}
}
configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) {
Expand Down Expand Up @@ -132,15 +126,3 @@ configure(subprojects.findAll { ['core', 'examples'].contains(it.name) }) {
}

}

if (Boolean.parseBoolean(enablePublishing)) {
apply plugin: 'io.codearte.nexus-staging'

nexusStaging {
packageGroup = 'org.mapfish'
serverUrl = "https://$host/service/local/"
username = sonatypeUsername
password = sonatypePassword
numberOfRetries = 200
}
}
7 changes: 7 additions & 0 deletions ci/docker-config.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "${TOKEN}"
}
}
}
41 changes: 41 additions & 0 deletions ci/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3

import os
import re
import subprocess


def publish(docker_version):
print("Deploying image to docker hub for tag " + docker_version)
subprocess.check_call(["./gradlew", "--console=plain", "createDocker"])
image_name = "camptocamp/mapfish_print:" + docker_version
subprocess.check_call(["docker", "tag", "camptocamp/mapfish_print:latest", image_name])
subprocess.check_call(["docker", "push", image_name])


def main():
if os.environ.get("GITHUB_EVENT_NAME") == "pull_request":
print("Not deploying image for pull requests")
exit(0)

branch_match = re.match("^refs/heads/(.*)$", os.environ["GITHUB_REF"])
tag_match = re.match("^refs/tags/(.*)$", os.environ["GITHUB_REF"])
if branch_match and branch_match.group(1) == "master":
publish("latest")

elif tag_match:
release_match = re.match("^release/(.*)$", tag_match.group(1))
publish(release_match.group(1) if release_match else tag_match.group(1))
if release_match:
print("Publishing")
subprocess.check_call(["./gradlew", "publish"])

elif branch_match:
publish(branch_match.group(1))

else:
print("Not deploying image")


if __name__ == "__main__":
main()
File renamed without changes.
1 change: 0 additions & 1 deletion circleci/dockercfg.enc

This file was deleted.

Binary file removed circleci/gradle.properties.enc
Binary file not shown.
Loading

0 comments on commit 8aed4cc

Please sign in to comment.