Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/workflows/clarin-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
name: CLARIN frontend release
on:
pull_request:
branches: [clarin-v7]
push:
branches: [clarin-v7]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: clarin-release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
if: github.repository == 'LUMII-AILab/dspace-angular'
runs-on: ubuntu-24.04
timeout-minutes: 60
outputs:
digest: ${{ steps.build.outputs.digest }}
image: ${{ steps.inputs.outputs.image }}
tag: ${{ steps.inputs.outputs.tag }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- name: Derive source identity and validate release tooling
id: inputs
run: |
python3 -m unittest discover -s ci/release -p 'test_release.py'
python3 ci/release/frontend_image.py outputs >> "$GITHUB_OUTPUT"
mkdir -p output/evidence
cp ci/release/image/inputs.json output/evidence/inputs.json
- name: Export this commit without submodules
id: source
run: |
python3 ci/release/frontend_image.py prepare-source \
"$RUNNER_TEMP/source-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \
output/evidence >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
with:
version: ${{ steps.inputs.outputs.buildx_version }}
driver-opts: image=${{ steps.inputs.outputs.buildkit_image }}
buildkitd-flags: ""
- name: Build once without registry credentials
id: build
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: ci/release/image
file: ci/release/image/Dockerfile
build-contexts: frontend=${{ steps.source.outputs.context }}
platforms: linux/amd64
push: false
outputs: type=oci,dest=output/frontend.oci.tar
tags: ${{ steps.inputs.outputs.image }}:${{ steps.inputs.outputs.tag }}
cache-from: type=gha,scope=clarin-frontend
cache-to: ${{ github.event_name != 'pull_request' && 'type=gha,scope=clarin-frontend,mode=max' || '' }}
provenance: mode=max
attests: type=sbom,generator=${{ steps.inputs.outputs.sbom_generator }}
build-args: |
NODE_IMAGE=${{ steps.inputs.outputs.node_image }}
NODE_VERSION=${{ steps.inputs.outputs.node_version }}
YARN_VERSION=${{ steps.inputs.outputs.yarn_version }}
APK_PACKAGES=${{ steps.inputs.outputs.apk_packages }}
SOURCE_PACKAGE_SHA256=${{ steps.inputs.outputs.source_package_sha256 }}
SOURCE_LOCK_SHA256=${{ steps.inputs.outputs.source_lock_sha256 }}
UPSTREAM_DOCKERFILE_SHA256=${{ steps.inputs.outputs.upstream_dockerfile_sha256 }}
SOURCE_REVISION=${{ steps.inputs.outputs.source_revision }}
OPS_REVISION=${{ steps.inputs.outputs.compatibility_revision }}
- name: Verify OCI identity, scan and load the exact runtime image
env:
EXPECTED_DIGEST: ${{ steps.build.outputs.digest }}
SKOPEO: ${{ steps.inputs.outputs.skopeo_image }}
run: |
python3 ci/release/frontend_image.py inspect output/frontend.oci.tar \
"$EXPECTED_DIGEST" output/evidence
bash ci/release/scan.sh output/frontend.oci.tar output/evidence
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD/output:/artifact" \
"$SKOPEO" copy --override-os linux --override-arch amd64 \
oci-archive:/artifact/frontend.oci.tar docker-archive:/artifact/runtime.tar:clarin-runtime:test
docker load --input output/runtime.tar
rm output/runtime.tar
- name: Qualify the exact artifact against pinned HTTPS fixtures
env:
CLARIN_COMPAT_ROOT: ${{ github.workspace }}/ci/release/compatibility
SOURCE: ${{ steps.inputs.outputs.source_revision }}
run: |
python3 -m venv "$RUNNER_TEMP/ansible"
"$RUNNER_TEMP/ansible/bin/pip" install ansible-core==2.21.3
export PATH="$RUNNER_TEMP/ansible/bin:$PATH"
docker pull nginx@sha256:dc5069ad14f19660b141b21236140b91656bf89bbc3e2417c70ae650cd66104c
python3 ci/release/test_https_runtime.py \
--frontend "$(jq -er .config_digest output/evidence/identity.json)" \
--source "$SOURCE" --report output/evidence/https.json
python3 ci/release/record.py
- name: Preserve candidate for publication retries
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: frontend-candidate-${{ github.run_id }}
path: output/
overwrite: true
retention-days: 30
compression-level: 0
if-no-files-found: error
publish:
needs: build
if: >-
github.event_name != 'pull_request' && github.ref == 'refs/heads/clarin-v7' &&
github.repository == 'LUMII-AILab/dspace-angular' &&
vars.CLARIN_RELEASE_PUBLISH_ENABLED == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: frontend-candidate-${{ github.run_id }}
path: output
- name: Publish tested artifact and durable release reports
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GHCR_USER: ${{ github.actor }}
EXPECTED_DIGEST: ${{ needs.build.outputs.digest }}
IMAGE: ${{ needs.build.outputs.image }}
TAG: ${{ needs.build.outputs.tag }}
run: |
cp output/evidence/inputs.json ci/release/image/inputs.json
python3 ci/release/verify_record.py
bash ci/release/publish.sh
python3 ci/release/publish_report.py
3 changes: 3 additions & 0 deletions ci/release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
image/inputs.json
!image/pm2/package-lock.json
91 changes: 91 additions & 0 deletions ci/release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# CLARIN frontend releases

The CLARIN workflow validates PRs to `clarin-v7` without registry/deployment
credentials. A mainline push builds one OCI artifact, verifies source identity,
provenance and SBOM, scans the image and dependency locks, and qualifies that exact
runtime image with disposable HTTPS fixtures. Publication copies that artifact
without rebuilding, verifies the registry digest, then creates a GitHub release
`sha-FULL_COMMIT` with small JSON reports. No server deployment runs in CI.

`image/toolchain.json` owns pinned Node/Yarn/PM2, APK, Buildx/BuildKit, scanner and
publisher versions. Source revision and package/lock hashes are derived from the
checked-out commit; `image/inputs.json` is generated. The source context is a Git
archive without submodule contents. Frozen dependency installation and persistent
BuildKit `gha` cache retain dependency layers; PRs only read the trusted cache.
A PR build and a mainline build validate different commits. Warm-cache speed is
not established until real runs measure it.

## Activation and retries

The existing GHCR package is `ghcr.io/lumii-ailab/dspace-angular`. Before enabling
publication, review its linked repository, private visibility, deployment reader
access and Actions access for `LUMII-AILab/dspace-angular`. Grant the app repository
write access through the package's **Manage Actions access**, preserving the existing
package/reader. Do not delete/recreate the package or change visibility.
Then set repository variable `CLARIN_RELEASE_PUBLISH_ENABLED=true`. The one-time
switch is separate from the automatic per-merge flow. The current CLI cannot inspect
package permissions (missing `read:packages`); this review/activation remains pending.
See [GitHub package access](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility).

Merge/push and workflow execution require their own requested publication scope.
Verify a real PR run and a real mainline release before claiming the automation is
operational. The retired ops publisher must not be used for new releases. The
existing Latvian publication remains preserved and its target rollout paused.

If publication fails, use **Re-run failed jobs**, retaining the successful build's
`frontend-candidate-RUN_ID` artifact (30 days). The publisher rechecks its digest,
source, reports and runtime identity. Do not rerun all jobs merely to retry a push:
that recompiles and may produce a different digest. An existing image tag cannot
be moved by this publisher. A full rebuild of the same source needs a deliberate
new source commit/version; the stable release tag must keep its original digest.
Manual dispatch is available for an intentional unreleased commit or recovery.

Report uploads use a draft release and verify every existing asset before publishing.
An interrupted draft can resume; existing different assets are never overwritten.
The GitHub release retains small reports beyond CI archive retention. Ops consumes
`release.json` from the trusted successful mainline workflow, selects the exact
recorded digest, and validates its source/config identity after the target pull.
This is repository/workflow trust, not signature verification. Reports cannot
replace the registry image or a recovery backup.

## Compatibility and security scope

Ops is private. `compatibility/manifest.json` identifies the immutable ops revision
and SHA-256 of the four public frontend/proxy templates plus public paths vendored
here. `compatibility/tests/render.yml` renders only these synthetic fixtures; it
contains no target inventory, credential or private configuration. This avoids
private repository credentials in app PR jobs. Update the compatibility revision,
fixture hashes and ops release validator together when the contract changes.

The HTTPS suite covers mock-backend routing, public configuration sanitization,
forwarding/header rejection, DNS/TLS and restart behavior. It does not establish
integrated DSpace content, authenticated access, browser Anubis behavior or
production acceptance. Ops adds bounded deployment probes and configured synthetic
file fixtures; usability changes still need owner acceptance.

`scan-policy.json` versions the existing **report-only synthetic** policy. Scanner
errors fail the build; findings remain visible in both retained Trivy reports.
No production security acceptance or vulnerability exception is inferred. An
owner-reviewed baseline and exceptions with owner, scope and expiry must precede
a future "new findings" gate; this change does not invent a baseline decision.

Local offline checks:

```sh
python3 -m unittest discover -s ci/release -p test_release.py
bash -n ci/release/scan.sh ci/release/publish.sh
```

The complete artifact test runs in CI. To exercise the disposable harness locally,
use an already-loaded exact config digest with `--frontend`, its source label with
`--source`, and `CLARIN_COMPAT_ROOT=$PWD/ci/release/compatibility`. No implicit pull
or rebuild is performed by the harness. CI explicitly pulls only the pinned proxy
and loads the verified runtime from its OCI archive.

Inherited upstream workflows are preserved byte-for-byte in
`.github/disabled-workflows/upstream/`, including the old customer dispatch,
DockerHub tagging, deployment and triage jobs. They are inactive in this fork.
This also removes obsolete CodeQL actions, an empty workflow and a missing local
reusable deployment workflow from active Actions configuration without upgrading
upstream tooling. CLARIN's focused release workflow is the fork's PR/mainline entry
point; it does not claim to run the upstream full Cypress/backend test matrix.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ansible-managed rehearsal configuration; contains no credentials.
ui:
ssl: true
host: {{ clarin_public_host | default('repository.clarin.test') }}
bindAddress: 0.0.0.0
useProxies: true
port: {{ clarin_public_port | default(443) }}
nameSpace: {{ clarin_ui_prefix }}/
rest:
ssl: true
host: {{ clarin_public_host | default('repository.clarin.test') }}
port: {{ clarin_public_port | default(443) }}
nameSpace: {{ clarin_rest_prefix }}
ssrBaseUrl: http://dspace:8080/repository/server
universal:
replaceRestUrl: true
transferState: false
matomo:
hostUrl: ''
siteId: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"apps": [{
"name": "dspace-ui",
"cwd": "/app",
"script": "/app/config/http-launcher.cjs",
"instances": 1,
"exec_mode": "fork",
"node_args": "--max-old-space-size=1024",
"max_memory_restart": "1500M",
"time": true,
"kill_timeout": 25000,
"env": {"NODE_ENV": "production"}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Public HTTPS is terminated by Nginx; this listener stays on the private network.
'use strict';
const { app } = require('/app/dist/server/main.js');
const server = app().listen(4000, '0.0.0.0');
const sockets = new Set();
server.on('connection', socket => {
sockets.add(socket);
socket.on('close', () => sockets.delete(socket));
});
let stopping = false;
function shutdown() {
if (stopping) return;
stopping = true;
server.close(() => process.exit(0));
if (server.closeIdleConnections) server.closeIdleConnections();
setTimeout(() => {
for (const socket of sockets) socket.destroy();
process.exit(0);
}, 20000).unref();
}
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);
Loading
Loading