Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
feat: first version
Browse files Browse the repository at this point in the history
  • Loading branch information
chgl committed Jul 8, 2024
1 parent 6f1c46a commit 6b463b2
Show file tree
Hide file tree
Showing 15 changed files with 927 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build IG
on:
push:
branches:
- master
pull_request:
branches:
- master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch: {}

# Declare default permissions as read only.
permissions: read-all

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: write
pages: write
container: ghcr.io/miracum/ig-build-tools:v2.0.60@sha256:814931d3ef33fb0ceccbd9dc6253e512eba0be83e7800559ce1cf5fd8cb52114
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Setup Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- name: build ig
working-directory: PseudonymizationIG/
run: |
java -jar /usr/local/bin/publisher.jar -ig ig.ini
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
# Upload entire repository
path: "PseudonymizationIG/output"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
if: ${{ github.event_name != 'pull_request' }}
7 changes: 7 additions & 0 deletions PseudonymizationIG/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
Thumbs.db
/fsh-generated
/input-cache
/output
/temp
/template
27 changes: 27 additions & 0 deletions PseudonymizationIG/_genonce.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@ECHO OFF
SET publisher_jar=publisher.jar
SET input_cache_path=%CD%\input-cache

ECHO Checking internet connection...
PING tx.fhir.org -4 -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
ECHO We're offline...
SET txoption=-tx n/a
GOTO igpublish

:isonline
ECHO We're online
SET txoption=

:igpublish

SET JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8

IF EXIST "%input_cache_path%\%publisher_jar%" (
JAVA -jar "%input_cache_path%\%publisher_jar%" -ig . %txoption% %*
) ELSE If exist "..\%publisher_jar%" (
JAVA -jar "..\%publisher_jar%" -ig . %txoption% %*
) ELSE (
ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
)

PAUSE
30 changes: 30 additions & 0 deletions PseudonymizationIG/_genonce.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
publisher_jar=publisher.jar
input_cache_path=./input-cache/
echo Checking internet connection...
curl -sSf tx.fhir.org > /dev/null

if [ $? -eq 0 ]; then
echo "Online"
txoption=""
else
echo "Offline"
txoption="-tx n/a"
fi

echo "$txoption"

export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8"

publisher=$input_cache_path/$publisher_jar
if test -f "$publisher"; then
java -jar $publisher -ig . $txoption $*

else
publisher=../$publisher_jar
if test -f "$publisher"; then
java -jar $publisher -ig . $txoption $*
else
echo IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
fi
fi
219 changes: 219 additions & 0 deletions PseudonymizationIG/_updatePublisher.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
@ECHO OFF

SETLOCAL

SET dlurl=https://github.com/HL7/fhir-ig-publisher/releases/latest/download/publisher.jar
SET publisher_jar=publisher.jar
SET input_cache_path=%CD%\input-cache\
SET skipPrompts=false

SET scriptdlroot=https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main
SET update_bat_url=%scriptdlroot%/_updatePublisher.bat
SET gen_bat_url=%scriptdlroot%/_genonce.bat
SET gencont_bat_url=%scriptdlroot%/_gencontinuous.bat
SET gencont_sh_url=%scriptdlroot%/_gencontinuous.sh
SET gen_sh_url=%scriptdlroot%/_genonce.sh
SET update_sh_url=%scriptdlroot%/_updatePublisher.sh

IF "%~1"=="/f" SET skipPrompts=y


ECHO.
ECHO Checking internet connection...
PING tx.fhir.org -4 -n 1 -w 1000 | FINDSTR TTL && GOTO isonline
ECHO We're offline, nothing to do...
GOTO end

:isonline
ECHO We're online


:processflags
SET ARG=%1
IF DEFINED ARG (
IF "%ARG%"=="-f" SET FORCE=true
IF "%ARG%"=="--force" SET FORCE=true
SHIFT
GOTO processflags
)

FOR %%x IN ("%CD%") DO SET upper_path=%%~dpx

ECHO.
IF NOT EXIST "%input_cache_path%%publisher_jar%" (
IF NOT EXIST "%upper_path%%publisher_jar%" (
SET jarlocation="%input_cache_path%%publisher_jar%"
SET jarlocationname=Input Cache
ECHO IG Publisher is not yet in input-cache or parent folder.
REM we don't use jarlocation below because it will be empty because we're in a bracketed if statement
GOTO create
) ELSE (
ECHO IG Publisher FOUND in parent folder
SET jarlocation="%upper_path%%publisher_jar%"
SET jarlocationname=Parent folder
GOTO upgrade
)
) ELSE (
ECHO IG Publisher FOUND in input-cache
SET jarlocation="%input_cache_path%%publisher_jar%"
SET jarlocationname=Input Cache
GOTO upgrade
)

:create
IF DEFINED FORCE (
MKDIR "%input_cache_path%" 2> NUL
GOTO download
)

IF "%skipPrompts%"=="y" (
SET create=Y
) ELSE (
SET /p create="Ok? (Y/N) "
)
IF /I "%create%"=="Y" (
ECHO Will place publisher jar here: %input_cache_path%%publisher_jar%
MKDIR "%input_cache_path%" 2> NUL
GOTO download
)
GOTO done

:upgrade
IF "%skipPrompts%"=="y" (
SET overwrite=Y
) ELSE (
SET /p overwrite="Overwrite %jarlocation%? (Y/N) "
)

IF /I "%overwrite%"=="Y" (
GOTO download
)
GOTO done

:download
ECHO Downloading most recent publisher to %jarlocationname% - it's ~100 MB, so this may take a bit

FOR /f "tokens=4-5 delims=. " %%i IN ('ver') DO SET VERSION=%%i.%%j
IF "%version%" == "10.0" GOTO win10
IF "%version%" == "6.3" GOTO win8.1
IF "%version%" == "6.2" GOTO win8
IF "%version%" == "6.1" GOTO win7
IF "%version%" == "6.0" GOTO vista

ECHO Unrecognized version: %version%
GOTO done

:win10
CALL POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%dlurl%\",\"%jarlocation%\") } else { Invoke-WebRequest -Uri "%dlurl%" -Outfile "%jarlocation%" }

GOTO done

:win7
rem this may be triggering the antivirus - bitsadmin.exe is a known threat
rem CALL bitsadmin /transfer GetPublisher /download /priority normal "%dlurl%" "%jarlocation%"

rem this didn't work in win 10
rem CALL Start-BitsTransfer /priority normal "%dlurl%" "%jarlocation%"

rem this should work - untested
call (New-Object Net.WebClient).DownloadFile('%dlurl%', '%jarlocation%')
GOTO done

:win8.1
:win8
:vista
GOTO done



:done




ECHO.
ECHO Updating scripts
IF "%skipPrompts%"=="y" (
SET updateScripts=Y
) ELSE (
SET /p updateScripts="Update scripts? (Y/N) "
)
IF /I "%updateScripts%"=="Y" (
GOTO scripts
)
GOTO end


:scripts

REM Download all batch files (and this one with a new name)

SETLOCAL DisableDelayedExpansion



:dl_script_1
ECHO Updating _updatePublisher.sh
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%update_sh_url%\",\"_updatePublisher.new.sh\") } else { Invoke-WebRequest -Uri "%update_sh_url%" -Outfile "_updatePublisher.new.sh" }
if %ERRORLEVEL% == 0 goto upd_script_1
echo "Errors encountered during download: %errorlevel%"
goto dl_script_2
:upd_script_1
start copy /y "_updatePublisher.new.sh" "_updatePublisher.sh" ^&^& del "_updatePublisher.new.sh" ^&^& exit


:dl_script_2
ECHO Updating _genonce.bat
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gen_bat_url%\",\"_genonce.new.bat\") } else { Invoke-WebRequest -Uri "%gen_bat_url%" -Outfile "_genonce.bat" }
if %ERRORLEVEL% == 0 goto upd_script_2
echo "Errors encountered during download: %errorlevel%"
goto dl_script_3
:upd_script_2
start copy /y "_genonce.new.bat" "_genonce.bat" ^&^& del "_genonce.new.bat" ^&^& exit

:dl_script_3
ECHO Updating _gencontinuous.bat
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gencont_bat_url%\",\"_gencontinuous.new.bat\") } else { Invoke-WebRequest -Uri "%gencont_bat_url%" -Outfile "_gencontinuous.bat" }
if %ERRORLEVEL% == 0 goto upd_script_3
echo "Errors encountered during download: %errorlevel%"
goto dl_script_4
:upd_script_3
start copy /y "_gencontinuous.new.bat" "_gencontinuous.bat" ^&^& del "_gencontinuous.new.bat" ^&^& exit


:dl_script_4
ECHO Updating _genonce.sh
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gen_sh_url%\",\"_genonce.new.sh\") } else { Invoke-WebRequest -Uri "%gen_sh_url%" -Outfile "_genonce.sh" }
if %ERRORLEVEL% == 0 goto upd_script_4
echo "Errors encountered during download: %errorlevel%"
goto dl_script_5
:upd_script_4
start copy /y "_genonce.new.sh" "_genonce.sh" ^&^& del "_genonce.new.sh" ^&^& exit

:dl_script_5
ECHO Updating _gencontinuous.sh
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%gencont_sh_url%\",\"_gencontinuous.new.sh\") } else { Invoke-WebRequest -Uri "%gencont_sh_url%" -Outfile "_gencontinuous.sh" }
if %ERRORLEVEL% == 0 goto upd_script_5
echo "Errors encountered during download: %errorlevel%"
goto dl_script_6
:upd_script_5
start copy /y "_gencontinuous.new.sh" "_gencontinuous.sh" ^&^& del "_gencontinuous.new.sh" ^&^& exit



:dl_script_6
ECHO Updating _updatePublisher.bat
call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\"%update_bat_url%\",\"_updatePublisher.new.bat\") } else { Invoke-WebRequest -Uri "%update_bat_url%" -Outfile "_updatePublisher.new.bat" }
if %ERRORLEVEL% == 0 goto upd_script_6
echo "Errors encountered during download: %errorlevel%"
goto end
:upd_script_6
start copy /y "_updatePublisher.new.bat" "_updatePublisher.bat" ^&^& del "_updatePublisher.new.bat" ^&^& exit


:end


IF "%skipPrompts%"=="true" (
PAUSE
)
Loading

0 comments on commit 6b463b2

Please sign in to comment.