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
173 changes: 173 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Release Mailtrain v3

on:
push:
tags: ['v3.*']

permissions:
contents: read

concurrency:
group: mailtrain-release
cancel-in-progress: false

jobs:
release:
if: github.repository == 'Mailtrain-org/mailtrain'
runs-on: ubuntu-24.04
timeout-minutes: 60
environment: mailtrain-release
permissions:
contents: write
id-token: write
env:
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_ENVIRONMENT: mailtrain-release
RELEASE_APPROVED_TAG: ${{ vars.RELEASE_APPROVED_TAG }}
DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }}
DOCKERHUB_OIDC_SUBJECT: ${{ vars.DOCKERHUB_OIDC_SUBJECT }}
PLAYWRIGHT_BROWSERS_PATH: /tmp/mailtrain-e2e-browsers
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache-dependency-path: e2e/package-lock.json
- name: Prepare the release notes and package metadata
id: prepare
run: |
node --test scripts/release.test.js
node scripts/release.js "$RELEASE_TAG" --output "$RUNNER_TEMP/mailtrain-release"
- name: Check publishing configuration
id: publisher
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
if [[ -z "$DOCKERHUB_OIDC_CONNECTIONID$DOCKERHUB_OIDC_SUBJECT$DOCKERHUB_USERNAME$DOCKERHUB_TOKEN" ]]; then
echo 'No Docker Hub publishing configuration. Build and test only.'
echo 'mode=none' >> "$GITHUB_OUTPUT"
else
node scripts/release.js "$RELEASE_TAG" --require-publisher
if [[ -n "$DOCKERHUB_OIDC_CONNECTIONID" ]]; then
echo 'mode=oidc' >> "$GITHUB_OUTPUT"
else
echo 'mode=token' >> "$GITHUB_OUTPUT"
fi
fi
- name: Refuse an existing release or a moved tag
uses: actions/github-script@v7
with:
script: |
const {execFileSync} = require('node:child_process');
const commit = execFileSync('git', ['rev-parse', 'HEAD'], {encoding: 'utf8'}).trim();
const tagged = await github.rest.repos.getCommit({...context.repo, ref: process.env.RELEASE_TAG});
if (tagged.data.sha !== commit) throw new Error('Release tag no longer matches checkout');
try {
await github.rest.repos.getReleaseByTag({...context.repo, tag: process.env.RELEASE_TAG});
throw new Error('Release already exists; inspect it rather than overwriting');
} catch (error) {
if (error.status !== 404) throw error;
}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
# Load each image once; publish these qualified images without rebuilding.
- name: Build amd64
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
load: true
push: false
tags: mailtrain-release:amd64
cache-from: type=gha,scope=mailtrain-amd64
cache-to: type=gha,mode=max,scope=mailtrain-amd64
- name: Build arm64
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
load: true
push: false
tags: mailtrain-release:arm64
cache-from: type=gha,scope=mailtrain-arm64
cache-to: type=gha,mode=max,scope=mailtrain-arm64
- name: Qualify the release images
run: |
npm ci --prefix e2e --no-audit --no-fund
node e2e/node_modules/playwright/cli.js install --with-deps chromium
for arch in amd64 arm64; do
docker run --rm --entrypoint npm -w /app/server "mailtrain-release:$arch" test
docker run --rm --entrypoint npm -w /app/zone-mta "mailtrain-release:$arch" test
MAILTRAIN_IMAGE="mailtrain-release:$arch" MAILTRAIN_PLATFORM="linux/$arch" npm test --prefix e2e
done
MAILTRAIN_IMAGE=mailtrain-release:amd64 MAILTRAIN_PLATFORM=linux/amd64 npm run test:upgrade --prefix e2e
- name: Check the issued OIDC claims before Docker login
if: steps.publisher.outputs.mode == 'oidc'
uses: actions/github-script@v7
with:
script: |
const token = await core.getIDToken();
const claims = JSON.parse(Buffer.from(token.split('.')[1], 'base64url').toString());
const expected = {
sub: process.env.DOCKERHUB_OIDC_SUBJECT,
repository: 'Mailtrain-org/mailtrain',
environment: 'mailtrain-release',
ref: context.ref,
workflow_ref: `Mailtrain-org/mailtrain/.github/workflows/release.yml@${context.ref}`
};
for (const [key, value] of Object.entries(expected)) {
if (claims[key] !== value) throw new Error(`OIDC ${key} mismatch; check the repository subject template and Docker ruleset`);
}
- name: Sign in to Docker Hub with organization OIDC
if: steps.publisher.outputs.mode == 'oidc'
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
with:
username: mailtrain
- name: Sign in with the configured Docker Hub token
if: steps.publisher.outputs.mode == 'token'
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish the tested multi-platform image
if: steps.publisher.outputs.mode != 'none'
env:
VERSION: ${{ steps.prepare.outputs.version }}
PRERELEASE: ${{ steps.prepare.outputs.prerelease }}
run: |
for arch in amd64 arm64; do
docker tag "mailtrain-release:$arch" "mailtrain/mailtrain:$VERSION-$arch"
docker push "mailtrain/mailtrain:$VERSION-$arch"
done
docker buildx imagetools create --tag "mailtrain/mailtrain:$VERSION" \
"mailtrain/mailtrain:$VERSION-amd64" "mailtrain/mailtrain:$VERSION-arm64"
docker buildx imagetools inspect "mailtrain/mailtrain:$VERSION" --raw > "$RUNNER_TEMP/mailtrain-release/manifest.json"
jq -e '[.manifests[] | select(.annotations["vnd.docker.reference.type"] != "attestation-manifest") | .platform | .os + "/" + .architecture] | sort == ["linux/amd64", "linux/arm64"]' "$RUNNER_TEMP/mailtrain-release/manifest.json"
if [ "$PRERELEASE" = false ]; then
docker buildx imagetools create --tag mailtrain/mailtrain:latest "mailtrain/mailtrain:$VERSION"
docker buildx imagetools inspect mailtrain/mailtrain:latest --raw > "$RUNNER_TEMP/mailtrain-release/latest.json"
cmp "$RUNNER_TEMP/mailtrain-release/manifest.json" "$RUNNER_TEMP/mailtrain-release/latest.json"
fi
- name: Create the GitHub release with the prepared notes
if: steps.publisher.outputs.mode != 'none'
uses: actions/github-script@v7
with:
script: |
const fs = require('node:fs');
const path = require('node:path');
const {execFileSync} = require('node:child_process');
const payload = JSON.parse(fs.readFileSync(path.join(process.env.RUNNER_TEMP, 'mailtrain-release/github-release.json')));
const commit = execFileSync('git', ['rev-parse', 'HEAD'], {encoding: 'utf8'}).trim();
const tagged = await github.rest.repos.getCommit({...context.repo, ref: payload.tag_name});
if (tagged.data.sha !== commit) throw new Error('Release tag moved after qualification');
const created = await github.rest.repos.createRelease({...context.repo, ...payload, target_commitish: commit});
const readback = await github.rest.repos.getRelease({...context.repo, release_id: created.data.id});
for (const key of ['tag_name', 'name', 'body', 'draft', 'prerelease']) {
if (readback.data[key] !== payload[key]) throw new Error(`Published release ${key} mismatch; inspect before retrying`);
}
core.info(readback.data.html_url);
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# Changelog

## 3.0.0-rc.1

This release candidate is for testing fresh installations and supported v2
upgrades on a copy of the deployment. See [README.md](https://github.com/Mailtrain-org/mailtrain/blob/v3.0.0-rc.1/README.md) for installation
and [UPGRADE.md](https://github.com/Mailtrain-org/mailtrain/blob/v3.0.0-rc.1/UPGRADE.md) before moving existing data.

* Modernize the server and client on Tomas Bureš's v3 foundation: Node 24
images, Express 5, Knex 3, React 18, Bootstrap 5 and webpack 5. Keep Mosaico
and the HTML/MJML code editor, and the more granular v3 permission model.
* Build from lockfiles with the pinned public MJML submodule. Provide non-root
amd64/arm64 images, persistent Compose services, healthchecks and an optional
builtin ZoneMTA profile compatible with Node 24.
* Escape simple merge-tag values in HTML messages and public archives (#1396,
@p-w). Verify SNS signatures and restrict confirmation/certificate URLs
(#1389); add optional provider webhook verification and private reporting
guidance. Read SECURITY.md for configuration and remaining limits.
* Preserve v2 data, files and migration history. The administrator archive
opens original GrapesJS and CKEditor templates, retired campaigns,
triggers and reports. Templates also open as HTML in the code editor.
Retired campaigns and queued triggers stay inactive.
* Fix segment nesting/reordering, dirty-page navigation, date controls,
Mosaico placeholders and v3 forms. Exercise real campaign delivery,
unsubscribe, browser areas, restart persistence and v2 admission in CI.
* Add send-configuration CC/BCC (#1390, @falkensteg-gmbh), stronger generated
session secrets and configurable Docker UI languages (#1186, #1185,
@jonathanmmm), subscription email prefilling (#981, @PabloCastellano),
translated preferences (#1105, @usrflo), and URL-prefix-safe message links.
* Remove Google Fonts from the UI and default templates (#1219,
@jonathanmmm). Update German (#1107, @usrflo; #1232, @codiflow; #1253,
@jonathanmmm), Austrian German and unsubscribe notices (#1393, @caichat),
Basque (#1367, @enbata), Russian registration (#1303, @iafilin), Spanish
(#961, @tanoxyz), Brazilian Portuguese (#900, @geisimarrech87) and Dutch
(#861, @Zir0h) translations for the current v3 interface.

Thanks to @bures for the v3 implementation, the contributors credited above for
their original changes, and @auscaster for integration, security hardening,
builds, regression coverage and release preparation. Original commit authorship
is retained for the community ports.

The external v2 token API, retired editors, automated campaign execution and
custom reporting remain inactive in v3. See the upgrade guide for role checks,
file ownership and backup recovery.

## 2.0.0-rc1 2018-12-25

* This is a complete rewrite of Mailtrain v1 with many features added. Just check it out.
113 changes: 89 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# Mailtrain v3

## Run it
Test Mailtrain **3.0.0-rc.1** upgrades on a copy. Read [UPGRADE.md](UPGRADE.md)
for the procedure and the legacy records available in the archive.
[RELEASING.md](RELEASING.md) covers release preparation.

## Install with Docker

Docker Engine/Desktop with Compose v2 supports both `linux/amd64` and
`linux/arm64`. Once the release is published, use its pinned version:

```sh
git clone --branch v3.0.0-rc.1 --recurse-submodules https://github.com/Mailtrain-org/mailtrain.git
cd mailtrain
export MAILTRAIN_IMAGE=mailtrain/mailtrain:3.0.0-rc.1
docker compose pull mysql redis mailtrain
docker compose up -d --no-build --wait
```

The RC never updates `latest`. Keep the explicit version in deployment
configuration. The Compose file includes a source build, so `--no-build` selects
the pulled release artifact. For a local build of a reviewed checkout, follow
"Run the source with Docker" below. Existing v2 installations must follow the
upgrade procedure before attaching their data.

## Run the source with Docker

The container uses Node 24 LTS. The native `posix` dependency does not compile on Node 26.

Expand All @@ -9,6 +32,7 @@ Install Docker with Compose v2, then clone v3 including its public submodule:
```sh
git clone --branch v3 --recurse-submodules https://github.com/Mailtrain-org/mailtrain.git
cd mailtrain
unset MAILTRAIN_IMAGE
docker compose up --build
```

Expand Down Expand Up @@ -67,38 +91,79 @@ legacy archive, incomplete-history and role fixtures against MariaDB. See [UPGRA
before upgrading an existing deployment.

Each test removes its own Compose project and volumes on exit. No external SMTP
provider or secrets are needed. CI runs both suites on amd64 on pull requests and
v2/v3 pushes, and also builds arm64 on pushes to v3. Set `E2E_EVIDENCE_DIR` to retain
provider or secrets are needed. v3 CI runs both suites on amd64 for pull requests
and pushes. Pushes to v3 also build arm64. v2 uses a separate Node 10 compatibility
check. Set `E2E_EVIDENCE_DIR` to retain
upgrade SQL snapshots and results locally; these contain disposable fixture data
and should not be published as production backups.

## Building it
## Install and run from source

1. Install Node.js 24 and npm, plus Python 3, make and a C++ compiler for native dependencies. Mosaico placeholder rendering also needs ImageMagick with the DejaVu-Sans font; the Docker image includes both.
Use Node.js **24** and its npm on Linux, Git, Python 3, make and a C++ compiler
for native dependencies. Install ImageMagick and the DejaVu-Sans font (Debian:
`imagemagick fonts-dejavu-core`). Provision MariaDB 11.4 and Redis 7, reachable
from the host. The Compose database defaults are private to its Docker network;
source processes need host-reachable services. MongoDB is unnecessary when
`builtinZoneMTA.enabled` is false; select an external SMTP provider instead.

2. Get Mailtrain from git
```
git clone --branch v3 --recurse-submodules https://github.com/Mailtrain-org/mailtrain.git
cd mailtrain
git checkout v3
```
After publication, clone the release with its pinned submodule, then build:

3. Build the pinned MJML browser dependency and install packages from their lockfiles.
```
sh client/build-mjml.sh
for dir in client shared server zone-mta; do (cd "$dir" && npm ci); done
```
```sh
git clone --branch v3.0.0-rc.1 --recurse-submodules https://github.com/Mailtrain-org/mailtrain.git
cd mailtrain
sh client/build-mjml.sh
for dir in shared client server zone-mta; do (cd "$dir" && npm ci); done
(cd client && npm run build)
```

Create an empty `mailtrain` SQL database and a dedicated user with privileges
on that database, including schema migrations. Do not use the root database
account. Write `server/config/production.json` with your database credentials,
Redis address, URL bases and a random session secret. For a local installation
with services on the default localhost ports, this creates the file once:

```sh
node <<'NODE'
const fs = require('node:fs');
const crypto = require('node:crypto');
fs.writeFileSync('server/config/production.json', JSON.stringify({
mysql: {host: '127.0.0.1', port: 3306, database: 'mailtrain', user: 'mailtrain', password: 'replace-with-database-password'},
redis: {enabled: true, host: '127.0.0.1', port: 6379},
builtinZoneMTA: {enabled: false},
www: {
host: '127.0.0.1', secret: crypto.randomBytes(32).toString('hex'),
trustedUrlBase: 'http://localhost:3000',
sandboxUrlBase: 'http://localhost:3003',
publicUrlBase: 'http://localhost:3004'
}
}, null, 2), {flag: 'wx', mode: 0o600});
NODE
```

4. Build the client.
```
(cd client && npm run build)
```
Replace the sample SQL password before starting. Keep the configuration and
`server/files` writable by the service user and retain both with database backups.
Use one production configuration file; adapt other settings against
`server/config/default.yaml`. For a new installation only, initialize an admin
password, then start the server:

Alternatively, when doing the development, run `npm run watch` in client. This builds the client, but keeps
watching for changes in client source files. It recompiles the client upon any changes in the sources.
```sh
cd server
NODE_ENV=production node setup/docker-entrypoint-db-setup.js 'replace-with-initial-password' ''
NODE_ENV=production node index.js
```

The Docker entrypoint accepts `ENABLED_LANGUAGES` as a comma-separated list of registered language codes,
for example `en-US, de-DE, eu`. If unset, the default enabled languages are used.
Open <http://localhost:3000> and sign in as `admin` with that password. The server
runs in the foreground; stop with Ctrl-C. A service manager must use the same
`server` working directory, production environment, configuration and file paths.
Initialization is automatic on startup too; without the explicit bootstrap the
fresh-database login is `admin` / `test`. Existing account credentials survive
startup. Run `npm test --prefix server` and `npm test --prefix zone-mta` from the
repository root for regression checks.

For development, run `npm run watch --prefix client` in a second terminal. The
Docker entrypoint accepts `ENABLED_LANGUAGES` as a comma-separated list of registered
codes, for example `en-US, de-DE, eu`; source installs use `enabledLanguages` in
their production configuration.

## GeoLite2
```
Expand Down
Loading
Loading