Nightly Build #192
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nightly Build | |
on: | |
push: | |
tags: | |
- "v*.*.*-*" | |
schedule: | |
- cron: "0 0 * * *" # Run every day at 00:00 UTC | |
workflow_dispatch: | |
env: | |
DOCKER_PLATFORMS: | | |
linux/386 | |
linux/amd64 | |
linux/amd64/v2 | |
linux/amd64/v3 | |
linux/arm/v5 | |
linux/arm/v6 | |
linux/arm/v7 | |
linux/arm64 | |
linux/ppc64le | |
linux/riscv64 | |
linux/s390x | |
QEMU_PLATFORMS: | | |
linux/386 | |
linux/amd64 | |
linux/arm/v6 | |
linux/arm/v7 | |
linux/arm64 | |
linux/ppc64le | |
linux/riscv64 | |
linux/s390x | |
# Variables set by scripts/ci.py | |
GORELEASER_PREVIOUS_TAG: "[not set]" | |
GORELEASER_CURRENT_TAG: "[not set]" | |
BUILD_VERSION: "[not set]" | |
CACHE_KEY: "[not set]" | |
MEMOS_VERSION: "[not set]" | |
jobs: | |
front-end: | |
name: Build front-end | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | |
with: | |
fetch-depth: 0 | |
# setup deps | |
- name: Setup Task | |
uses: jaxxstorm/action-install-gh-release@25d5e2dd555cd74f1fab9ac1e6ea117acde2c0c4 | |
with: | |
repo: go-task/task | |
cache: enable | |
tag: "v3.34.1" | |
- name: Setup pnpm | |
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 | |
with: | |
version: 9 | |
- name: Setup Node | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 | |
with: | |
node-version: 20 | |
cache: pnpm | |
cache-dependency-path: "memos/web/pnpm-lock.yaml" | |
# /setup deps | |
- name: Pull latest changes from usememos/memos:main to subtree | |
run: python scripts/ci.py pull-subtree --branch=main | |
- name: Setup environment variables | |
run: python scripts/ci.py setup-env --nightly | |
- name: Cache front-end build | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 | |
with: | |
path: | | |
memos/server/router/frontend/dist/ | |
.task/checksum/build-frontend | |
key: | | |
frontend-${{env.BUILD_VERSION}}-${{ env.CACHE_KEY }} | |
restore-keys: | | |
frontend-${{env.BUILD_VERSION}}- | |
- name: Build front-end | |
run: task build:frontend | |
- name: Upload front-end artifact | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 | |
with: | |
name: frontend_${{env.BUILD_VERSION}} | |
compression-level: 9 | |
if-no-files-found: error | |
path: | | |
memos/server/router/frontend/dist/ | |
.task/checksum/build-frontend | |
goreleaser: | |
name: Build | |
runs-on: ubuntu-22.04 | |
permissions: | |
actions: read # required by wait action | |
contents: write | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 | |
with: | |
fetch-depth: 0 | |
# setup deps | |
- name: Setup Task | |
uses: jaxxstorm/action-install-gh-release@25d5e2dd555cd74f1fab9ac1e6ea117acde2c0c4 | |
with: | |
repo: go-task/task | |
cache: enable | |
tag: "v3.34.1" | |
- name: Setup buf | |
uses: bufbuild/buf-setup-action@f1331ea1d3f74482cbb60ac19f47fa098232b059 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
version: 1.29.0 | |
- name: Setup UPX | |
uses: crazy-max/ghaction-upx@0fc45e912669ba9e8fa2b430e97c8da2a632e29b | |
with: | |
install-only: true | |
- name: Setup Go | |
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 | |
with: | |
go-version: ">=1.22" | |
check-latest: true | |
cache-dependency-path: memos/go.sum | |
- name: Setup Goreleaser | |
uses: jaxxstorm/action-install-gh-release@25d5e2dd555cd74f1fab9ac1e6ea117acde2c0c4 | |
with: | |
repo: goreleaser/goreleaser | |
cache: enable | |
tag: "v2.0.0" | |
# /setup deps | |
- name: Pull latest changes from usememos/memos:main to subtree | |
run: python scripts/ci.py pull-subtree --branch=main | |
- name: Setup environment variables | |
run: python scripts/ci.py setup-env --nightly | |
### Front-end ### | |
- name: Wait for the front-end build to finish | |
uses: yogeshlonkar/wait-for-jobs@b12a68ffdc2782330f359a2c6b3ce4cb96a11652 | |
with: | |
jobs: "Build front-end" | |
interval: "2000" | |
ttl: "10" | |
- name: Download front-end artifact | |
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e | |
with: | |
name: frontend_${{env.BUILD_VERSION}} | |
### /Front-end ### | |
- name: Cache back-end build | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 | |
with: | |
path: | | |
build/backend | |
./task/checksum/build-backend-nightly | |
key: | | |
nightly-backend-${{ env.BUILD_VERSION }}-${{ env.CACHE_KEY }} | |
restore-keys: | | |
nightly-backend-${{ env.BUILD_VERSION }}- | |
- name: Nightly build | |
run: task build:backend-nightly | |
- name: Create pre-release | |
uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87 | |
with: | |
files: | | |
build/backend/*.tar.gz | |
build/backend/*.zip | |
build/backend/*.txt | |
body: | | |
This is an **untested** pre-release, built with bleeding-edge upstream Memos code. | |
It is strongly recommended that you do *not* use it in production. | |
*Ensure that you use a different database than the one you use for stable releases.* | |
Version identifier `${{ env.BUILD_VERSION }}` is auto-generated, based on what is set at Memos upstream on `version.go` file. Therefore, pre-release versioning is subject to change without notice. | |
Release assets may be overwritten by the daily automated builds if the upstream Memos version hasn't changed. | |
**[Official Memos upstream changelog](https://github.com/usememos/memos/compare/${{ env.MEMOS_VERSION }}...main)** | |
tag_name: ${{ env.BUILD_VERSION }} | |
draft: false | |
prerelease: true | |
### Docker ### | |
- name: Rename goreleaser builds to the format expected by current Dockerfile | |
run: python scripts/ci.py rename-to-docker | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 | |
with: | |
platforms: ${{ env.QEMU_PLATFORMS }} | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb | |
with: | |
version: latest | |
install: true | |
platforms: ${{ env.DOCKER_PLATFORMS }} | |
- name: Log-in to Docker Hub | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
username: lincolnthalles | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Log-in to GitHub's Container registry | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
images: | | |
lincolnthalles/memos | |
ghcr.io/memospot/memos-builds | |
tags: | | |
type=raw,value=nightly | |
- name: Build and Push Docker images | |
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 | |
with: | |
context: ./ | |
file: ./docker/Dockerfile | |
platforms: ${{ env.DOCKER_PLATFORMS }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
### /Docker ### |