Skip to content

feat: restructure as multi-stack monorepo with shared CLI #8

feat: restructure as multi-stack monorepo with shared CLI

feat: restructure as multi-stack monorepo with shared CLI #8

Workflow file for this run

name: Release & Publish
on:
push:
branches: [main]
workflow_dispatch:
inputs:
version:
description: "Version tag to publish (e.g. v0.1.0). Skips semantic-release."
required: false
env:
REGISTRY: ghcr.io
jobs:
release:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
outputs:
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm-publish:
needs: [release]
if: needs.release.outputs.new_release_published == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Publish CLI to npm
working-directory: cli
run: |
npm version ${{ needs.release.outputs.new_release_version }} --no-git-tag-version
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Build each platform natively per stack (no QEMU emulation)
build:
needs: [release]
if: |
always() &&
(needs.release.outputs.new_release_published == 'true' || github.event_name == 'workflow_dispatch')
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
stack: [laravel]
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: stacks/${{ matrix.stack }}
platforms: ${{ matrix.platform }}
outputs: type=image,name=${{ env.REGISTRY }}/reyemtech/${{ matrix.stack }}-upgrade-agent,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ matrix.stack }}-${{ matrix.platform }}
cache-to: type=gha,scope=${{ matrix.stack }}-${{ matrix.platform }},mode=max
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.stack }}-${{ matrix.runner }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# Merge per-platform images into a single multi-arch manifest per stack
publish:
needs: [release, build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
stack: [laravel]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version
id: version
run: |
if [ -n "${{ inputs.version }}" ]; then
echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
elif [ -n "${{ needs.release.outputs.new_release_version }}" ]; then
echo "tag=v${{ needs.release.outputs.new_release_version }}" >> "$GITHUB_OUTPUT"
else
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
fi
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/reyemtech/${{ matrix.stack }}-upgrade-agent
tags: |
type=raw,value=latest
type=semver,pattern={{version}},value=${{ steps.version.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.tag }}
type=semver,pattern={{major}},value=${{ steps.version.outputs.tag }},enable=${{ !startsWith(steps.version.outputs.tag, 'v0.') }}
type=sha
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{ matrix.stack }}-*
merge-multiple: true
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/reyemtech/${{ matrix.stack }}-upgrade-agent@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/reyemtech/${{ matrix.stack }}-upgrade-agent:${{ steps.meta.outputs.version }}