Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Add automated `nightly` releases.

Kailash Nadh881bcd67c30f
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
new file mode 100644
index 00000000..27f68e6c
--- /dev/null
+++ b/.github/workflows/nightly.yml
@@ -0,0 +1,140 @@
+name: nightly
+on:
+ schedule:
+ - cron: "0 2 * * *"
+ workflow_dispatch:
+
+permissions:
+ contents: write
+ packages: write
+
+jobs:
+ check:
+ runs-on: ubuntu-latest
+ outputs:
+ skip: ${{ steps.check_changes.outputs.skip }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+ with:
+ fetch-depth: 0
+
+ - name: Check for changes since last nightly release
+ id: check_changes
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ LAST_NIGHTLY_SHA=$(gh release view nightly --json targetCommitish -q '.targetCommitish' 2>/dev/null || echo "")
+ CURRENT_SHA=$(git rev-parse HEAD)
+ echo "Last nightly SHA: $LAST_NIGHTLY_SHA"
+ echo "Current SHA: $CURRENT_SHA"
+ if [ -n "$LAST_NIGHTLY_SHA" ] && [ "$LAST_NIGHTLY_SHA" = "$CURRENT_SHA" ]; then
+ echo "No changes since last nightly build, skipping ..."
+ echo "skip=true" >> $GITHUB_OUTPUT
+ else
+ echo "Changes detected, proceeding with build ..."
+ echo "skip=false" >> $GITHUB_OUTPUT
+ fi
+
+ nightly:
+ needs: check
+ if: needs.check.outputs.skip != 'true'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+ with:
+ fetch-depth: 0
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: "1.25.6"
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Delete existing nightly release
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: gh release delete nightly --yes --cleanup-tag 2>/dev/null || true
+
+ - name: Set nightly date
+ id: tag
+ run: |
+ NIGHTLY_DATE=$(date -u +%Y-%m-%d)
+ echo "date=$NIGHTLY_DATE" >> $GITHUB_OUTPUT
+
+ - name: Prepare dependencies
+ run: make dist
+ env:
+ LISTMONK_VERSION: nightly-${{ steps.tag.outputs.date }}
+
+ - name: Run GoReleaser
+ uses: goreleaser/goreleaser-action@v6
+ with:
+ version: latest
+ args: release --snapshot --parallelism 1 --clean --config .goreleaser-nightly.yml
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ LISTMONK_VERSION: nightly-${{ steps.tag.outputs.date }}
+
+ - name: Push Docker images
+ run: |
+ # Push all architecture-specific images
+ docker push listmonk/listmonk:nightly-amd64
+ docker push listmonk/listmonk:nightly-arm64v8
+ docker push listmonk/listmonk:nightly-armv6
+ docker push listmonk/listmonk:nightly-armv7
+ docker push ghcr.io/knadh/listmonk:nightly-amd64
+ docker push ghcr.io/knadh/listmonk:nightly-arm64v8
+ docker push ghcr.io/knadh/listmonk:nightly-armv6
+ docker push ghcr.io/knadh/listmonk:nightly-armv7
+
+ - name: Create and push Docker manifests
+ run: |
+ # Docker Hub manifest
+ docker manifest create listmonk/listmonk:nightly \
+ listmonk/listmonk:nightly-amd64 \
+ listmonk/listmonk:nightly-arm64v8 \
+ listmonk/listmonk:nightly-armv6 \
+ listmonk/listmonk:nightly-armv7
+ docker manifest push listmonk/listmonk:nightly
+
+ # GHCR manifest
+ docker manifest create ghcr.io/knadh/listmonk:nightly \
+ ghcr.io/knadh/listmonk:nightly-amd64 \
+ ghcr.io/knadh/listmonk:nightly-arm64v8 \
+ ghcr.io/knadh/listmonk:nightly-armv6 \
+ ghcr.io/knadh/listmonk:nightly-armv7
+ docker manifest push ghcr.io/knadh/listmonk:nightly
+
+ - name: Create GitHub Release
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ gh release create nightly \
+ --title "Nightly release" \
+ --notes "
+ > **Warning**: This is an automated nightly build from the master branch.
+ > It may contain bugs and breaking changes. Use at your own risk.
+ > Available on Docker Hub and GitHub Container Registry as `listmonk/listmonk:nightly`.
+ > For stable releases, please use a versioned release. [Learn more](https://listmonk.app/docs/installation/#nightly)
+
+ Built from commit: $(git rev-parse --short HEAD)" \
+ --prerelease \
+ --target $(git rev-parse HEAD) \
+ dist/*.tar.gz
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index fff6d71d..e32eed11 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -12,26 +12,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up QEMU
- uses: docker/setup-qemu-action@v2
+ uses: docker/setup-qemu-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: "1.24.1"
+ go-version: "1.25.6"
- name: Login to Docker Registry
- uses: docker/login-action@v2
+ uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Docker Registry
- uses: docker/login-action@v2
+ uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -46,7 +46,7 @@ jobs:
docker version
- name: Run GoReleaser
- uses: goreleaser/goreleaser-action@v5
+ uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --parallelism 1 --clean
diff --git a/.goreleaser-nightly.yml b/.goreleaser-nightly.yml
new file mode 100644
index 00000000..002e28ac
--- /dev/null
+++ b/.goreleaser-nightly.yml
@@ -0,0 +1,168 @@
+version: 2
+
+snapshot:
+ version_template: "{{ .Env.LISTMONK_VERSION }}"
+
+# GoReleaser config for nightly builds
+
+env:
+ - GO111MODULE=on
+ - CGO_ENABLED=0
+ - GITHUB_ORG=knadh
+ - DOCKER_ORG=listmonk
+
+before:
+ hooks:
+ - make build-frontend
+
+builds:
+ - binary: listmonk
+ main: ./cmd
+ goos:
+ - linux
+ - windows
+ - darwin
+ - freebsd
+ - openbsd
+ - netbsd
+ goarch:
+ - amd64
+ - arm64
+ - arm
+ goarm:
+ - 6
+ - 7
+ ldflags:
+ - -s -w -X "main.buildString=nightly ({{ .ShortCommit }} {{ .Date }}, {{ .Os }}/{{ .Arch }})" -X "main.versionString={{ .Env.LISTMONK_VERSION }}"
+
+ hooks:
+ # stuff executables with static assets.
+ post: make pack-bin BIN={{ .Path }}
+
+archives:
+ - format: tar.gz
+ name_template: "listmonk_nightly_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
+ files:
+ - README.md
+ - LICENSE
+
+dockers:
+ - use: buildx
+ goos: linux
+ goarch: amd64
+ ids:
+ - listmonk
+ image_templates:
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-amd64"
+ - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-amd64"
+ build_flag_templates:
+ - --platform=linux/amd64
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
+ - --label=org.opencontainers.image.description={{ .ProjectName }}
+ - --label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.version=nightly
+ - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
+ - --label=org.opencontainers.image.licenses=AGPL-3.0
+ dockerfile: Dockerfile
+ extra_files:
+ - config.toml.sample
+ - docker-entrypoint.sh
+ - use: buildx
+ goos: linux
+ goarch: arm64
+ ids:
+ - listmonk
+ image_templates:
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-arm64v8"
+ - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-arm64v8"
+ build_flag_templates:
+ - --platform=linux/arm64/v8
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
+ - --label=org.opencontainers.image.description={{ .ProjectName }}
+ - --label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.version=nightly
+ - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
+ - --label=org.opencontainers.image.licenses=AGPL-3.0
+ dockerfile: Dockerfile
+ extra_files:
+ - config.toml.sample
+ - docker-entrypoint.sh
+ - use: buildx
+ goos: linux
+ goarch: arm
+ goarm: 6
+ ids:
+ - listmonk
+ image_templates:
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-armv6"
+ - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-armv6"
+ build_flag_templates:
+ - --platform=linux/arm/v6
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
+ - --label=org.opencontainers.image.description={{ .ProjectName }}
+ - --label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.version=nightly
+ - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
+ - --label=org.opencontainers.image.licenses=AGPL-3.0
+ dockerfile: Dockerfile
+ extra_files:
+ - config.toml.sample
+ - docker-entrypoint.sh
+ - use: buildx
+ goos: linux
+ goarch: arm
+ goarm: 7
+ ids:
+ - listmonk
+ image_templates:
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-armv7"
+ - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-armv7"
+ build_flag_templates:
+ - --platform=linux/arm/v7
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
+ - --label=org.opencontainers.image.description={{ .ProjectName }}
+ - --label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}
+ - --label=org.opencontainers.image.version=nightly
+ - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
+ - --label=org.opencontainers.image.licenses=AGPL-3.0
+ dockerfile: Dockerfile
+ extra_files:
+ - config.toml.sample
+ - docker-entrypoint.sh
+
+docker_manifests:
+ - name_template: "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly"
+ image_templates:
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-amd64"
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-arm64v8"
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-armv6"
+ - "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:nightly-armv7"
+ - name_template: ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly
+ image_templates:
+ - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-amd64
+ - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-arm64v8
+ - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-armv6
+ - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:nightly-armv7
+
+changelog:
+ disable: true
+
+release:
+ prerelease: true
+ name_template: "Nightly Build"
+ header: |
+ ## Nightly Build
+
+ > **Warning**: This is an automated nightly build from the master branch.
+ > It may contain bugs and breaking changes. Use at your own risk.
+ > For stable releases, please use a versioned release.
+
+ Built from commit: {{ .ShortCommit }}
diff --git a/cmd/main.go b/cmd/main.go
index 784b5fc7..acede3d9 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -149,6 +149,9 @@ func init() {
os.Exit(0)
}
+ // Is this a nightly build?
+ isNightly := strings.Contains(versionString, "nightly")
+
// Check if the DB schema is installed.
if ok, err := checkSchema(db); err != nil {
log.Fatalf("error checking schema in DB: %v", err)
@@ -157,12 +160,23 @@ func init() {
}
if ko.Bool("upgrade") {
- upgrade(db, fs, !ko.Bool("yes"))
+ // Even on explicit upgrade runs, for nightly builds, do not record the last
+ // migration version in the DB.
+ lo.Printf("running upgrade...")
+ upgrade(db, fs, !ko.Bool("yes"), !isNightly)
os.Exit(0)
}
- // Before the queries are prepared, see if there are pending upgrades.
- checkUpgrade(db)
+ // For nightly builds, always auto-run pending migrations without
+ // recording the last version in the DB. Migrations are idempotent, and between
+ // nightly releases, they may change multiple times.
+ if isNightly {
+ lo.Printf("auto-running all migrations for nightly %s since last major version", versionString)
+ upgrade(db, fs, false, false)
+ } else {
+ // Before the queries are prepared, see if there are pending upgrades.
+ checkUpgrade(db)
+ }
// Read the SQL queries from the queries file.
qMap := readQueries(queryFilePath, fs)
diff --git a/cmd/upgrade.go b/cmd/upgrade.go
index 7c0312d3..62b47d08 100644
--- a/cmd/upgrade.go
+++ b/cmd/upgrade.go
@@ -47,7 +47,8 @@ var migList = []migFunc{
// upgrade upgrades the database to the current version by running SQL migration files
// for all version from the last known version to the current one.
-func upgrade(db *sqlx.DB, fs stuffbin.FileSystem, prompt bool) {
+// If record is false, migration versions are not recorded in the DB (used for nightly builds).
+func upgrade(db *sqlx.DB, fs stuffbin.FileSystem, prompt bool, record bool) {
if prompt {
var ok string
fmt.Printf("** IMPORTANT: Take a backup of the database before upgrading.\n")
@@ -81,11 +82,14 @@ func upgrade(db *sqlx.DB, fs stuffbin.FileSystem, prompt bool) {
// Record the migration version in the settings table. There was no
// settings table until v0.7.0, so ignore the no-table errors.
- if err := recordMigrationVersion(m.version, db); err != nil {
- if isTableNotExistErr(err) {
- continue
+ // For nightly builds, skip recording so migrations re-run on each boot.
+ if record {
+ if err := recordMigrationVersion(m.version, db); err != nil {
+ if isTableNotExistErr(err) {
+ continue
+ }
+ lo.Fatalf("error recording migration version %s: %v", m.version, err)
}
- lo.Fatalf("error recording migration version %s: %v", m.version, err)
}
}
diff --git a/docs/docs/content/installation.md b/docs/docs/content/installation.md
index 6bffc95c..8f084043 100644
--- a/docs/docs/content/installation.md
+++ b/docs/docs/content/installation.md
@@ -34,8 +34,6 @@ Then, visit `http://localhost:9000` to create the Super Admin user and login.
`LISTMONK_ADMIN_USER=myuser LISTMONK_ADMIN_PASSWORD=xxxxx docker compose up -d`
-------------
-
### Mounting a custom config.toml
The docker-compose file includes all necessary listmonk configuration as environment variables, `LISTMONK_*`.
If you would like to remove those and mount a config.toml instead:
@@ -74,6 +72,18 @@ max_lifetime = "300s"
command: [sh, -c, "./listmonk --install --idempotent --yes --config /listmonk/config.toml && ./listmonk --upgrade --yes --config /listmonk/config.toml && ./listmonk --config /listmonk/config.toml"]
```
+-----------
+
+## Nightly
+
+!!! Warning
+ Nightly releases are untested and may have bugs. Use at your own risk. Always take a backup of your Postgres database before using a nightly release.
+
+A nightly build is automatically published with the latest changes merged to the repository. If you want to access the latest changes without waiting for versioned releases, you can obtain the nightly builds and follow the same instructions above.
+
+- **Docker**: `listmonk/listmonk:nightly` (use this as the image name in the docker-compose file)
+- **Binary**: [Download nightly release](https://github.com/knadh/listmonk/releases/nightly)
+
## Compiling from source
@@ -83,9 +93,6 @@ To compile the latest unreleased version (`master` branch):
2. `git clone [email protected]:knadh/listmonk.git`
3. `cd listmonk && make dist`. This will generate the `listmonk` binary.
-## Release candidate (RC)
-
-The `master` branch with bleeding edge changes is periodically built and published as `listmonk/listmonk:rc` on DockerHub. To run the latest pre-release version, replace all instances of `listmonk/listmonk:latest` with `listmonk/listmonk:rc` in the docker-compose.yml file and follow the Docker installation steps above. While it is generally safe to run release candidate versions, they may have issues that only get resolved in a general release.
## Helm chart for Kubernetes
diff --git a/docs/docs/content/upgrade.md b/docs/docs/content/upgrade.md
index c0369972..2dae351b 100644
--- a/docs/docs/content/upgrade.md
+++ b/docs/docs/content/upgrade.md
@@ -30,13 +30,10 @@ docker-compose pull && docker-compose run --rm app ./listmonk --upgrade
docker-compose up -d app db
```
+## Nightly
+See [here](installation.md#nightly) for instructions on how to access the nightly builds.
-## Railway
-- Head to your dashboard, and select your Listmonk project.
-- Select the GitHub deployment service.
-- In the Deployment tab, head to the latest deployment, click on the three vertical dots to the right, and select "Redeploy".
-
-![Railway Redeploy option](https://user-images.githubusercontent.com/55474996/226517149-6dc512d5-f862-46f7-a57d-5e55b781ff53.png)
+-----------
## Downgrade
@@ -83,3 +80,11 @@ It is safe to upgrade an older installation with `--upgrade`, but there are a fe
1. **API credentials**: If you are using APIs to interact with listmonk, after logging in, go to Settings -> Users and create a new API user with the necessary permissions. Change existing API integrations to use these credentials instead of the old username and password defined in the legacy TOML configuration file or environment variables.
1. **Credentials in TOML file or old environment variables**: The admin dashboard shows a warning until the `admin_username` and `admin_password` fields are removed from the configuration file or old environment variables. In v4.x.x, these are irrelevant as user credentials are stored in the database and managed from the admin UI. IMPORTANT: if you are using APIs to interact with listmonk, follow the previous step before removing the legacy credentials.
+
+
+## Railway
+- Head to your dashboard, and select your Listmonk project.
+- Select the GitHub deployment service.
+- In the Deployment tab, head to the latest deployment, click on the three vertical dots to the right, and select "Redeploy".
+
+![Railway Redeploy option](https://user-images.githubusercontent.com/55474996/226517149-6dc512d5-f862-46f7-a57d-5e55b781ff53.png)