Skip to content

Commit

Permalink
support for release through Github (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
qtips authored Dec 13, 2022
1 parent 2eb3de4 commit a048ca0
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 78 deletions.
26 changes: 26 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
58 changes: 0 additions & 58 deletions .github/workflows/deploy.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 12 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: Run tests
name: Build PR
on:
push:
branches-ignore:
- master
paths-ignore:
- '**.md'
- '**.MD'
- '.gitignore'
- 'LICENCE'
- 'CODEOWNERS'

jobs:
build:
Expand All @@ -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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<release>

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}
Expand Down Expand Up @@ -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:<release>

COPY templates /app/templates # handlebars templates
COPY fonts /app/fonts # fonts to be embedded
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit a048ca0

Please sign in to comment.