Skip to content

Commit aad1f7e

Browse files
authored
Merge pull request #255 from SwissOpenEM/253-tryout-create-choco-package-hosted-on-github
253 tryout create choco package hosted on GitHub
2 parents 56181a7 + 76ccfc3 commit aad1f7e

File tree

15 files changed

+297
-14
lines changed

15 files changed

+297
-14
lines changed

.github/workflows/release.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ on:
88

99
permissions:
1010
contents: write
11+
packages: write
12+
13+
env:
14+
NUGET_SOURCE_URL: "https://nuget.pkg.github.com/swissopenem/index.json"
15+
# For deploying within ETHZ w/o authorization that is required for public github access
16+
GITLAB_SOURCE_URL: "https://sissource.ethz.ch/api/v4/projects/1201/packages/nuget/index.json"
1117

1218
jobs:
1319
goreleaser:
@@ -30,6 +36,29 @@ jobs:
3036
args: release --clean
3137
env:
3238
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Set up .NET
41+
uses: actions/setup-dotnet@v2
42+
with:
43+
dotnet-version: 10.x.x
44+
45+
# AI Generated step to parse the version
46+
- name: Extract version from Git tag
47+
id: extract_version
48+
run: |
49+
VERSION=${GITHUB_REF##*/}
50+
echo "VERSION=${VERSION/v/}" >> $GITHUB_ENV
51+
52+
- name: Create NuGet package
53+
run: |
54+
nuget pack openem-ingestor.nuspec -version ${{env.VERSION}}
55+
56+
- name: Publish NuGet package to GitHub
57+
run: |
58+
nuget push *.nupkg -Source "${{env.NUGET_SOURCE_URL}}" -ApiKey ${{ secrets.GITHUB_TOKEN }}
59+
nuget push *.nupkg -Source "${{env.GITLAB_SOURCE_URL}}" -ApiKey ${{ secrets.SISSOURCE_GITLAB_NUGET_REPO }}
60+
61+
3362
build_docker_image_release:
3463
permissions:
3564
packages: write

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ go.work.sum
3030
dist/**
3131

3232
# backup files
33-
*.go.bak
33+
*.go.bak
34+
*.nupkg

.goreleaser.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ builds:
7171
flags:
7272
- -trimpath
7373
ldflags:
74-
- "-s -w -X 'main.version={{.Version}}'"
74+
- "-s -w -X 'main.version={{.Version}}' "
7575
env:
7676
- CGO_ENABLED=0
7777
dir: ./cmd/openem-ingestor-service
@@ -126,12 +126,10 @@ archives:
126126
{{- else }}{{ .Arch }}{{ end }}
127127
{{- if .Arm }}v{{ .Arm }}{{ end }}
128128
files:
129-
- src: configs/ReadMe.md
130-
dst: ./ReadMe.md
129+
- src: ./README.md
130+
dst: ./README.md
131131
- src: configs/*.yaml
132132
dst: ./
133-
- src: configs/schemas/*.json
134-
dst: schemas
135133

136134
changelog:
137135
sort: asc

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"command": "go",
3737
"args": [
3838
"generate",
39-
"./internal/*"
39+
"./internal/..."
4040
]
4141
},
4242
{

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ The core package contains main functionality. It makes use of the [scicat-cli to
5656
- WebServer: [docs/authentication.md](docs/webserver.md)
5757
- Keycloak Setup for development: [docs/keycloak-setup.md](docs/keycloak-setup.md)
5858

59-
## Deployment
59+
## Linux Deployment
6060

6161
For deployment instruction and example setup see [openem-deployment](https://github.com/SwissOpenEM/openem-deployment) repository.
62+
63+
## Windows Deployment
64+
65+
### Executable
66+
67+
The executable can be download directly from the [releases page](https://github.com/SwissOpenEM/Ingestor/releases) and executed. Alternatively,
68+
a [Chocolatey](https://docs.chocolatey.org/en-us/) package can be downloaded which installs the ingestor as a Windows service.
69+
70+
### Windows Service Deployment
71+
72+
1. Install Shawl <https://github.com/mtkennerly/shawl> with `machine` scope to run the ingestor as a Windows services
73+
```pwsh
74+
winget install --scope "machine" -e --id mtkennerly.shawl
75+
```
76+
77+
2. Install the ingestor using `chocolatey`
78+
79+
```pwsh
80+
choco install openem-ingestor --source=https://nuget.pkg.github.com/swissopenem/index.json --params="'/Scicat.Host=\"https://dacat.psi.ch/api/v3\"'" -y
81+
```
82+
83+
> **Note**: You will be prompted for a Github username and password as Github does not allow for unauthenticated downloads.
84+
85+
3. Verify the ingestor is up and running by entering `http://localhost:8888/version` in a browser. The install version should appear.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Scicat:
2+
Host: ${SCICAT_HOST}/api/v3
3+
Transfer:
4+
StorageLocation: "ETHZ"
5+
Method: S3
6+
S3:
7+
Endpoint: ${S3_HOST}/archiver/api/v1
8+
TokenUrl: ${KEYCLOAK_HOST}/realms/awi/protocol/openid-connect/token
9+
ClientID: scopem-archiver-service-api
10+
ChunkSizeMB: 128
11+
ConcurrentFiles: 8
12+
PoolSize: 4
13+
14+
MetadataExtractors:
15+
InstallationPath: C:\Users\Public\Documents\OpenEM\extractors
16+
SchemasLocation: C:\Users\Public\Documents\OpenEM\schemas
17+
DownloadMissingExtractors: true
18+
Timeout: 20m
19+
Extractors:
20+
- Name: LS
21+
GithubOrg: osc-em
22+
GithubProject: oscem-extractor-life
23+
Version: v2.0.2
24+
Executable: oscem-extractor-life.exe
25+
Checksum: 0f7f2ef8ec641795ef322c765a504fd6a5a287e70071a79f42f5f73a7c892b1f
26+
ChecksumAlg: sha256
27+
CommandLineTemplate: "-i '{{.SourceFolder}}' -o '{{.OutputFile}}' --cs 2.7 --folder_filter=^.*(?i)(metadata).*$"
28+
Methods:
29+
- Name: Single Particle
30+
Schema: oscem_schemas_spa.schema.json
31+
Url: https://w3id.org/oscem-schemas/latest/spa/jsonschema/oscem_schemas_spa.schema.json
32+
- Name: Cellular Tomography
33+
Schema: oscem_cellular_tomo.json
34+
Url: https://w3id.org/oscem-schemas/latest/cellular_tomo/jsonschema/oscem_schemas_cellular_tomo.schema.json
35+
- Name: Tomography
36+
Schema: oscem_tomo.json
37+
Url: https://w3id.org/oscem-schemas/latest/subtomo/jsonschema/oscem_schemas_subtomo.schema.json
38+
- Name: EnvironmentalTomography
39+
Schema: oscem_env_tomo.json
40+
Url: https://w3id.org/oscem-schemas/latest/env_tomo/jsonschema/oscem_schemas_env_tomo.schema.json
41+
WebServer:
42+
Auth:
43+
Disable: true
44+
SessionDuration: 28800
45+
Frontend:
46+
Origin: ${FRONTEND_HOST}
47+
RedirectPath: "/ingestor"
48+
OAuth2:
49+
ClientID: "ingestor"
50+
RedirectURL: "http://localhost:8888/callback"
51+
Scopes:
52+
- email
53+
OIDC:
54+
IssuerURL: "${KEYCLOAK_HOST}/realms/awi"
55+
JWT:
56+
UseJWKS: true
57+
JwksURL: "${KEYCLOAK_HOST}/realms/awi/protocol/openid-connect/certs"
58+
JwksSignatureMethods:
59+
- RS256
60+
RBAC:
61+
AdminRole: "ingestor-admin-scopem"
62+
CreateModifyTasksRole: "ingestor-write-scopem"
63+
ViewTasksRole: "ingestor-read-scopem"
64+
Paths:
65+
CollectionLocations:
66+
"${COLLECTION_LOCATION1}": "${COLLECTION_LOCATION1_PATH}"
67+
"${COLLECTION_LOCATION2}": "${COLLECTION_LOCATION2_PATH}"
68+
"${COLLECTION_LOCATION3}": "${COLLECTION_LOCATION3_PATH}"
69+
MetadataExtJobs:
70+
ConcurrencyLimit: 10
71+
QueueSize: 200
72+
Other:
73+
Port: 8888
74+
LogLevel: Info
75+
DisableServiceAccountCheck: true
76+
BackendAddress: http://localhost:8888

internal/metadataextractor/extractor.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"os"
1616
"os/exec"
1717
"path"
18+
"path/filepath"
1819
"regexp"
1920
"runtime"
2021
"sort"
@@ -106,7 +107,7 @@ func NewExtractorHandler(config ExtractorsConfig) *ExtractorHandler {
106107
if config.DownloadMissingExtractors {
107108
err := downloadExtractor(fullInstallPath, extractorConfig)
108109
if err != nil {
109-
log().Error("Failed to download extractor", "name", extractorConfig.Name)
110+
log().Error("Failed to download extractor", "name", extractorConfig.Name, "error", err.Error())
110111
continue
111112
}
112113
}
@@ -307,8 +308,8 @@ func downloadExtractor(fullInstallPath string, config ExtractorConfig) error {
307308
return err
308309
}
309310
x := &xtractr.XFile{
310-
FilePath: path.Clean(file),
311-
OutputDir: path.Dir(fullInstallPath),
311+
FilePath: filepath.Clean(file),
312+
OutputDir: filepath.Clean(path.Dir(fullInstallPath)),
312313
}
313314

314315
size, files, _, err := x.Extract()

internal/webserver/webserver.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import (
2323
"github.com/gin-contrib/slog"
2424
)
2525

26-
// Copy the openapi specs to local folder so it can be embedded in order to statically serve it
27-
//go:generate cp ../../api/openapi.yaml ./openapi.yaml
28-
2926
//go:embed openapi.yaml
3027
var swaggerYAML embed.FS
3128

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build linux
2+
3+
package webserver
4+
5+
// Copy the openapi specs to local folder so it can be embedded in order to statically serve it
6+
//go:generate cp ../../api/openapi.yaml ./openapi.yaml
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build windows
2+
3+
package webserver
4+
5+
// Copy the openapi specs to local folder so it can be embedded in order to statically serve it
6+
//go:generate cmd.exe /c copy ..\..\api\openapi.yaml .\openapi.yaml

0 commit comments

Comments
 (0)