diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..bb60a08 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,26 @@ +name-template: $NEXT_PATCH_VERSION +tag-template: $NEXT_PATCH_VERSION +change-template: '- $TITLE (#$NUMBER) @$AUTHOR' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '⚠️ Breaking Changes' + labels: + - 'breaking' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + labels: + - 'chore' + - title: '⬆️ Dependency upgrades' + labels: + - 'bump' + - 'dependencies' +template: | + ## What's Changed + $CHANGES diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bf590cf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: Build master +on: + push: + branches: + - master # Push events on master branch + paths-ignore: + - '**.md' + - '**.MD' + - '.gitignore' + - 'LICENCE' + - 'CODEOWNERS' + +jobs: + build: + name: Checkout code and run tests + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@master + - name: Set up Java 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + architecture: x64 + cache: 'gradle' + - name: Run tests + env: + ORG_GRADLE_PROJECT_githubUser: x-access-token + ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} + run: | + ./gradlew shadowJar \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 1e82adf..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Build and publish -on: - push: - branches: - - master - paths-ignore: - - README.md - - CODEOWNERS - -env: - IMAGE: ghcr.io/${{ github.repository }} -jobs: - build: - name: Build and push docker image - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@master - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - architecture: x64 - - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('build.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle-cache- - - uses: actions/cache@v3 - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper- - - name: Run tests - env: - ORG_GRADLE_PROJECT_githubUser: x-access-token - ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} - run: | - ./gradlew test - - name: Build jar - env: - ORG_GRADLE_PROJECT_githubUser: x-access-token - ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} - run: | - ./gradlew shadowJar -x test - echo "VERSION=$(./gradlew -q printVersion)" >> $GITHUB_ENV - - name: Build Docker images - run: | - docker build --tag ${{ env.IMAGE }}:${{ env.VERSION }} . - - name: Push docker image to GitHub - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - docker login ghcr.io -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN} - docker push ${{ env.IMAGE }}:${{ env.VERSION }} diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 0000000..d871129 --- /dev/null +++ b/.github/workflows/release-image.yml @@ -0,0 +1,42 @@ +name: Publish master +on: + release: + types: [published] + +env: + IMAGE: ghcr.io/${{ github.repository }} + NEW_VERSION: ${{ github.event.release.tag_name }} + +jobs: + build: + name: Bygg pull-request + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: 'master' + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + architecture: x64 + cache: 'gradle' + - name: Build gradle artifacts + shell: bash + run: | + ./gradlew shadowJar + env: + ORG_GRADLE_PROJECT_githubUser: x-access-token + ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} + - name: Build Docker images + run: | + docker build --tag ${{ env.IMAGE }}:${{ env.NEW_VERSION }} . + - name: Push docker image to GitHub + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + docker login ghcr.io -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN} + docker push ${{ env.IMAGE }}:${{ env.NEW_VERSION }} + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 708e1aa..312d20f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,14 @@ -name: Run tests +name: Build PR on: push: branches-ignore: - master + paths-ignore: + - '**.md' + - '**.MD' + - '.gitignore' + - 'LICENCE' + - 'CODEOWNERS' jobs: build: @@ -14,24 +20,13 @@ jobs: - name: Set up Java 17 uses: actions/setup-java@v3 with: - distribution: 'temurin' - java-version: '17' - architecture: x64 - - uses: actions/cache@v3 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('build.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle-cache- - - uses: actions/cache@v1 - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle-wrapper- + distribution: 'temurin' + java-version: '17' + architecture: x64 + cache: 'gradle' - name: Run tests env: ORG_GRADLE_PROJECT_githubUser: x-access-token ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }} run: | - ./gradlew test + ./gradlew shadowJar diff --git a/README.md b/README.md index fb51a7d..77e5c7c 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,16 @@ In your own repository, create a Dockerfile with the following contents ```dockerfile # Dockerfile -FROM ghcr.io/navikt/pdfgen:2.0.0 +FROM ghcr.io/navikt/pdfgen: COPY templates /app/templates # handlebars templates COPY fonts /app/fonts # fonts to be embedded COPY resources /app/resources # additional resources ``` +Check Github releases to find the latest `release` version +Check [Github releases](https://github.com/navikt/pdfgen/releases) to find the latest `release` version + Set up the basic folder structure ```bash mkdir {templates,fonts,resources,data} @@ -79,7 +82,7 @@ A [licensed Adobe Acrobat DC](https://gist.github.com/karinaldw/1c4c321fe05bdc1e ```dockerfile # Dockerfile -FROM ghcr.io/navikt/pdfgen:2.0.0 +FROM ghcr.io/navikt/pdfgen: COPY templates /app/templates # handlebars templates COPY fonts /app/fonts # fonts to be embedded diff --git a/build.gradle.kts b/build.gradle.kts index be35b23..ca9b980 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile group = "no.nav.pdfgen" -version = "2.0.0" +version = "2.0.0" //This will never change. See Github releases for docker image release val handlebarsVersion = "4.3.0" val jacksonVersion = "2.14.1"