Skip to content

Commit

Permalink
Merge branch 'release/v1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bot committed Jun 10, 2024
2 parents 4596d86 + 9f6096f commit 03ed165
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 95 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Build and push
name: "Build and push"

on:
push:
branches:
- main
- develop
- release/*
pull_request:
branches:
- main
Expand All @@ -13,40 +14,35 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '21' ]

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to GitLab
- name: Docker - Login
uses: docker/login-action@v3
if: ${{ github.actor != 'dependabot[bot]' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Setup Java
- name: Setup - Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
java-version: '21'
cache: 'maven'

- name: Build
run: mvn --batch-mode --update-snapshots clean verify spring-boot:build-image

- name: Spotless
run: mvn spotless:check

- name: Build with Maven
run: mvn clean verify spring-boot:build-image

- name: Build and push
- name: Docker - Push
if: ${{ github.ref == 'refs/heads/main' }}
run: |
VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
echo ${VERSION}
docker push ehrbase/migration-tool:${VERSION}
113 changes: 113 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Create a Release
name: "Release"

on:
workflow_dispatch:
inputs:
version:
description: "optional: version to release"
required: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# This will be used by git in all further steps
# We need a PERSONAL ACCESS TOKEN so pushes trigger other GitHub actions
token: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Calculate realise version
run: |
if [ -z "${{ github.event.inputs.version }}" ]
then
v=$(grep -oPm1 "(?<=<version>)[^<]+" "pom.xml" | sed 's/-SNAPSHOT//')
echo ${{ github.repository }}
else
v=${{ github.event.inputs.version }}
fi
echo "realise version ${v}"
# Set as Environment for all further steps
echo "VERSION=${v}" >> $GITHUB_ENV
- name: Create Release Branch
run: |
# Config git
git config --global user.email "[email protected]"
git config --global user.name "bot"
# create branch
git checkout -b release/v${VERSION}
# Update version
mvn versions:set -DnewVersion=${VERSION} -DprocessAllModules=true
#edit changelog
replace="s/\[unreleased\]/\[${VERSION}\]/"
sed -i ${replace} CHANGELOG.md
replace="s/...HEAD/\...v${VERSION}/"
sed -i ${replace} CHANGELOG.md
# commit & push
git add -A
git commit -m "release ${VERSION}: updated version to ${VERSION}"
git push -u origin release/v${VERSION}
# wait for status of commit to change from pending
- name: Wait for ci pipeline
run: |
STATUS="pending"
# Get commit last commit of release branch
COMMIT=$(git rev-parse HEAD)
echo "Listen for commit $COMMIT"
WAITED="0"
# Time between calls
SLEEP_TIME="60"
while [ "$STATUS" == "pending" ] && [ "$WAITED" -le 1800 ]
do
sleep ${SLEEP_TIME}
WAITED=$((WAITED+SLEEP_TIME))
STATUS=$(gh api /repos/${{ github.repository }}/commits/"${COMMIT}"/status -q .state)
echo "status : $STATUS"
echo "waited $WAITED s"
done
echo "status : $STATUS"
if [ "$STATUS" != "success" ]
then exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Merge into Main
run: |
git checkout main
git pull
git merge --no-ff release/v${VERSION}
git tag -a -m "v${VERSION}" "v${VERSION}"
git push --follow-tags
- name: Create Release
run: |
gh release create "v${VERSION}" -t "v${VERSION}" -F CHANGELOG.md -R ${{ github.repository }} --target main
env:
GITHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Merge into dev
run: |
# increment minor version and add SNAPSHOT
ARRAY_VERSION=( ${VERSION//./ } )
git checkout release/v${VERSION}
NEXT_VERSION=${ARRAY_VERSION[0]}.$((ARRAY_VERSION[1]+1)).0-SNAPSHOT
echo "next version: $NEXT_VERSION"
# update version
mvn versions:set -DnewVersion=${NEXT_VERSION} -DprocessAllModules=true
#edit changelog
sed -i '5i ## [unreleased]\n ### Added \n ### Fixed \n' CHANGELOG.md
replace="$ a \[unreleased\]: https:\/\/github.com\/ehrbase\/openEHR_SDK\/compare\/v$VERSION...HEAD"
sed -i "${replace}" CHANGELOG.md
git add -A
git commit -m " updated version to ${NEXT_VERSION}"
git checkout develop
git pull
git merge --no-ff release/v${VERSION}
git push
23 changes: 23 additions & 0 deletions .github/workflows/status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Adds the results of a workflow as a commit status
name: "Set test status"

on:
workflow_run:
workflows: ["Build and push"] # runs after build and test workflow
types:
- completed

jobs:
set_status:
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- name: Create status
run: |
gh api repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_commit.id }} \
-f "state"="${{ github.event.workflow_run.conclusion }}" \
-f "context"="${{ github.event.workflow_run.event }}.${{ github.event.workflow_run.id}}"\
-f "target_url"="${{ github.event.workflow_run.html_url }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0]
### Fixed

- Fix class not found [[#9](https://github.com/ehrbase/migration-tool/pull/9)]

## [1.1.0]

Initial publicly available version.

[1.2.0]: https://github.com/ehrbase/migration-tool/compare/v1.1.0...v1.2.0
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ The target database needs to be prepared according to the instructions in the [E

## Performing the migration

The migration can be run directly from the source code, or the provided docker image.
The migration can be run directly from the source code, or the provided docker image. As a naming convention an `export`
datasource represents an EHRbase 0.x.x database where an `import` datasource represents an EHRbase 2 database.

The properties must be adjusted according to the set-up:

### Spring boot
Expand All @@ -28,10 +30,10 @@ mvn package
java -jar application/target/migration-tool.jar \
-Dmode=DB2DB \
-Dspring.datasource.import.url=jdbc:postgresql://localhost:5432/ehrbase_import \
-Dspring.datasource.import.url=jdbc:postgresql://localhost:5432/ehrbase_new \
-Dspring.datasource.import.username=ehrbase \
-Dspring.datasource.import.password=ehrbase \
-Dspring.datasource.export.url=jdbc:postgresql://localhost:5432/ehrbase_export \
-Dspring.datasource.export.url=jdbc:postgresql://localhost:5432/ehrbase_old \
-Dspring.datasource.export.username=ehrbase \
-Dspring.datasource.export.password=ehrbase \
-Dimport.ehrbase-db-user=ehrbase_restricted
Expand All @@ -43,10 +45,10 @@ mvn verify
docker run ehrbase/migration-tool:1.1.0 \
-e mode=DB2DB \
-e spring.datasource.import.url=jdbc:postgresql://localhost:5432/ehrbase_import \
-e spring.datasource.import.url=jdbc:postgresql://localhost:5432/ehrbase_new \
-e spring.datasource.import.username=ehrbase \
-e spring.datasource.import.password=ehrbase \
-e spring.datasource.export.url=jdbc:postgresql://localhost:5432/ehrbase_export \
-e spring.datasource.export.url=jdbc:postgresql://localhost:5432/ehrbase_old \
-e spring.datasource.export.username=ehrbase \
-e spring.datasource.export.password=ehrbase \
-e import.ehrbase-db-user=ehrbase_restricted
Expand Down
57 changes: 36 additions & 21 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

<groupId>org.ehrbase.migration</groupId>
<artifactId>migration-application</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>jar</packaging>
<name>EHRbase Migration Tool Application</name>

<properties>
<image.name>ehrbase/migration-tool</image.name>
<image.tag>${project.version}</image.tag>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<java.version>21</java.version>

<skipTests>false</skipTests>

<image.name>ehrbase/migration-tool</image.name>
<image.tag>${project.version}</image.tag>
</properties>

<dependencyManagement>
Expand All @@ -35,14 +38,16 @@
</dependencies>
</dependencyManagement>


<dependencies>

<!-- Compile -->
<dependency>
<groupId>org.ehrbase.migration</groupId>
<artifactId>migration-service</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -55,6 +60,10 @@
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
Expand All @@ -63,14 +72,11 @@
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
</dependency>

</dependencies>

<build>
Expand All @@ -85,6 +91,18 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down Expand Up @@ -132,6 +150,7 @@
<skip>false</skip>
</configuration>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -172,12 +191,21 @@
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>${skipTests}</skipTests>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipITs>${skipTests}</skipITs>
</configuration>
<executions>
<execution>
<id>integration-test</id>
Expand All @@ -196,19 +224,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Loading

0 comments on commit 03ed165

Please sign in to comment.