Skip to content

chore:ci: pull heads/release/0.21.0 from usememos/memos #72

chore:ci: pull heads/release/0.21.0 from usememos/memos

chore:ci: pull heads/release/0.21.0 from usememos/memos #72

Workflow file for this run

name: Build and Release
on:
push:
branches:
- "release/v*.*.*"
tags-ignore:
- "v*.*.*-*"
workflow_dispatch:
inputs:
memos-tag:
description: |
Upstream tag to build.
The action will fail if a matching tag already exists on this repository.
required: false
type: string
memos-release:
description: |
Upstream release to build.
The action will fail if a matching tag already exists on this repository.
required: false
type: string
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_CURRENT_TAG: "[not set]"
BUILD_VERSION: "[not set]"
CACHE_KEY: "[not set]"
jobs:
front-end:
name: Build front-end
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
fetch-depth: 0
# setup deps
- name: Setup Task
uses: jaxxstorm/action-install-gh-release@71d17cb091aa850acb2a1a4cf87258d183eb941b
with:
repo: go-task/task
cache: enable
tag: "v3.34.1"
- name: Setup pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d
with:
version: 8
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: 20
cache: pnpm
cache-dependency-path: "memos/web/pnpm-lock.yaml"
# /setup deps
# When running the workflow manually, allows to build a specific tag or release.
# If the build is triggered by other events, will build whatever is already commited to the subtree.
- if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.memos-release == '' && github.event.inputs.memos-tag != '' }}
name: Pull usememos/memos:tags/${{ inputs.memos-tag }} to subtree
run: python scripts/ci.py pull-subtree --branch=tags/${{ inputs.memos-tag }}
- if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.memos-tag == '' && github.event.inputs.memos-release != '' }}
name: Pull usememos/memos:releases/${{ inputs.memos-release }} to subtree
run: python scripts/ci.py pull-subtree --branch=heads/release/${{ inputs.memos-release }}
# Run after subtree pull, in case version.go changed.
- name: Setup environment variables
run: python scripts/ci.py setup-env
- name: Cache front-end build
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: |
build/frontend
.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@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: frontend_${{env.BUILD_VERSION}}
compression-level: 9
if-no-files-found: error
path: |
build/frontend/
.task/checksum/build-frontend
goreleaser:
name: Build back-end and Release
runs-on: ubuntu-22.04
permissions:
actions: read # required by wait action
contents: write
discussions: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
fetch-depth: 0
# setup deps
- name: Setup Task
uses: jaxxstorm/action-install-gh-release@71d17cb091aa850acb2a1a4cf87258d183eb941b
with:
repo: go-task/task
cache: enable
tag: "v3.34.1"
- name: Setup buf
uses: bufbuild/buf-setup-action@517ee23296d5caf38df31c21945e6a54bbc8a89f
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@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version: ">=1.22"
check-latest: true
cache-dependency-path: memos/go.sum
# /setup deps
# When running the workflow manually, allows to build a specific tag or release.
# If the build is triggered by other events, will build whatever is already commited to the subtree.
- if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.memos-release == '' && github.event.inputs.memos-tag != '' }}
name: Pull usememos/memos:tags/${{ inputs.memos-tag }} to subtree
run: |
python scripts/ci.py pull-subtree --branch=tags/${{ inputs.memos-tag }}
python scripts/ci.py retag --tag=v${{ inputs.memos-tag }} --push
- if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.memos-tag == '' && github.event.inputs.memos-release != '' }}
name: Pull usememos/memos:releases/${{ inputs.memos-release }} to subtree
run: |
python scripts/ci.py pull-subtree --branch=heads/release/${{ inputs.memos-release }}
python scripts/ci.py retag --tag=${{ inputs.memos-release }} --push
# Run after subtree pull, in case version.go changed.
- name: Setup environment variables
run: python scripts/ci.py setup-env
### Front-end ###
- name: Wait for the front-end build to finish
uses: yogeshlonkar/wait-for-jobs@e63eb7009ce730db926a5c4eeb9ba2bb5b2acb59
with:
jobs: "Build front-end"
interval: "2000"
ttl: "10"
- name: Download front-end artifact
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
with:
name: frontend_${{env.BUILD_VERSION}}
### /Front-end ###
- name: go.mod tidy
run: task build:backend-tidy
- name: Generate protobuf-related code
run: task build:buf
- name: Build and release with Goreleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8
with:
distribution: goreleaser
version: v1.24
args: release --clean --timeout 60m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
### 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@2b51285047da1547ffb1b2203d8be4c0af6b1f20
with:
version: latest
install: true
platforms: ${{ env.DOCKER_PLATFORMS }}
- name: Log-in to Docker Hub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
with:
username: lincolnthalles
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log-in to GitHub's Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
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/lincolnthalles/memos-builds
tags: |
type=raw,value=latest
type=semver,pattern={{version}},value=${{ env.BUILD_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.BUILD_VERSION }}
- name: Build and Push Docker images
id: docker_build
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 ###