-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b2f42a
commit 70c47f4
Showing
8 changed files
with
262 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: Docker | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
# Publish semver tags as releases. | ||
tags: [ 'v*.*.*' ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
# This is used to complete the identity challenge | ||
# with sigstore/fulcio when running outside of PRs. | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Install the cosign tool except on PR | ||
# https://github.com/sigstore/cosign-installer | ||
- name: Install cosign | ||
if: github.event_name != 'pull_request' | ||
uses: sigstore/[email protected] | ||
with: | ||
cosign-release: "v2.2.3" | ||
|
||
# Set up BuildKit Docker container builder to be able to build | ||
# multi-platform images and export cache | ||
# https://github.com/docker/setup-buildx-action | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
# Login against a Docker registry except on PR | ||
# https://github.com/docker/login-action | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
# Build and push Docker image with Buildx (don't push on PR) | ||
# https://github.com/docker/build-push-action | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
# Sign the resulting Docker image digest except on PRs. | ||
# This will only write to the public Rekor transparency log when the Docker | ||
# repository is public to avoid leaking data. If you would like to publish | ||
# transparency data even for private images, pass --force to cosign below. | ||
# https://github.com/sigstore/cosign | ||
- name: Sign the published Docker image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable | ||
TAGS: ${{ steps.meta.outputs.tags }} | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
# This step uses the identity token to provision an ephemeral certificate | ||
# against the sigstore community Fulcio instance. | ||
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,3 @@ gradle-app.setting | |
.classpath | ||
|
||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM gradle:8.10.1-jdk-alpine AS TEMP_BUILD_IMAGE | ||
ENV APP_HOME=/usr/app/ | ||
WORKDIR $APP_HOME | ||
COPY build.gradle settings.gradle $APP_HOME | ||
|
||
COPY gradle $APP_HOME/gradle | ||
COPY --chown=gradle:gradle . /home/gradle/src | ||
USER root | ||
RUN chown -R gradle /home/gradle/src | ||
|
||
RUN gradle build || return 0 | ||
COPY . . | ||
RUN gradle clean build | ||
|
||
# actual container | ||
FROM openjdk:17-alpine | ||
ENV ARTIFACT_NAME=app.jar | ||
ENV APP_HOME=/usr/app/ | ||
|
||
WORKDIR $APP_HOME | ||
|
||
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME . | ||
|
||
EXPOSE 8000 | ||
ENTRYPOINT exec java -jar ${ARTIFACT_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Basic Code Example using Gradle | ||
|
||
This minimal code example shows how to generate a QR bill. It uses the Gradle build system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,133 +1,28 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
|
||
plugins { | ||
id 'jacoco' | ||
id 'org.sonarqube' version '5.0.0.4638' | ||
id 'java-library' | ||
id 'maven-publish' | ||
id 'signing' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
group = 'net.codecrete.qrbill' | ||
version = '3.3.1' | ||
archivesBaseName = 'qrbill-generator' | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
|
||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes( | ||
'Implementation-Title': 'Swiss QR Bill Generator', | ||
'Implementation-Version': archiveVersion, | ||
'Implementation-Vendor': 'Manuel Bleichenbacher' | ||
) | ||
} | ||
} | ||
|
||
javadoc { | ||
include 'net/codecrete/qrbill/canvas/*' | ||
include 'net/codecrete/qrbill/generator/*' | ||
|
||
title = "QR Bill Generator ${version}" | ||
options.addBooleanOption('html5', true) | ||
} | ||
apply plugin: 'java' | ||
|
||
test { | ||
useJUnitPlatform() | ||
task execute(type: JavaExec) { | ||
mainClass = 'clic.epfl.qrbill.Main' | ||
classpath = sourceSets.main.runtimeClasspath | ||
} | ||
|
||
artifacts { | ||
archives javadocJar, sourcesJar | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
artifactId = 'qrbill-generator' | ||
from components.java | ||
|
||
pom { | ||
name = 'Swiss QR Bill' | ||
description = 'Java library for generating Swiss QR bills' | ||
url = 'https://github.com/manuelbl/SwissQRBill' | ||
licenses { | ||
license { | ||
name = 'The MIT License' | ||
url = 'https://opensource.org/licenses/MIT' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'manuelbl' | ||
name = 'Manuel Bleichenbacher' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:git://github.com/manuelbl/SwissQRBill.git' | ||
developerConnection = 'scm:git:ssh://github.com:manuelbl/SwissQRBill.git' | ||
url = 'https://github.com/manuelbl/SwissQRBill/tree/master' | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
def releaseRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releaseRepoUrl | ||
authentication { | ||
basic(BasicAuthentication) | ||
} | ||
credentials { | ||
username = findProperty('ossrhUsername') ?: 'unknown' | ||
password = findProperty('ossrhPassword') ?: 'unknown' | ||
} | ||
} | ||
} | ||
dependencies { | ||
implementation group: 'net.codecrete.qrbill', name: 'qrbill-generator', version: '3.+' | ||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' // Latest version | ||
} | ||
|
||
signing { | ||
required { gradle.taskGraph.hasTask('publish') || gradle.taskGraph.hasTask('publishToMavenLocal') } | ||
sign publishing.publications.mavenJava | ||
} | ||
jar { | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
|
||
sonar { | ||
properties { | ||
property 'sonar.projectName', 'Swiss QR Bill Generator (Java)' | ||
property 'sonar.organization', 'manuelbl-github' | ||
property 'sonar.host', 'https://sonarcloud.io' | ||
manifest { | ||
attributes 'Main-Class': 'clic.epfl.qrbill.Main' | ||
} | ||
} | ||
|
||
jacocoTestReport { | ||
dependsOn test | ||
reports { | ||
xml.required = true | ||
html.required = false | ||
csv.required = false | ||
from { | ||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } | ||
} | ||
} | ||
|
||
dependencies { | ||
api 'org.apache.pdfbox:pdfbox:3.0.3' | ||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2' // Latest version | ||
implementation 'io.nayuki:qrcodegen:1.8.0' | ||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2' | ||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
./gradlew clean execute |
Empty file.
Oops, something went wrong.