chore: fix release CI #116
This file contains hidden or 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: "Build & Push Docker" | |
| on: | |
| push: | |
| branches: | |
| - edge # Edge, tags as "edge"; next major version; deploys to edge.manifoldapp.org | |
| - main # Preview, tags as "preview"; bugfix/minor version preview; deploys to preview.manifoldapp.org | |
| - release # Stable production build, tags as "latest" and "<semver>" from MANIFOLD_VERSION | |
| workflow_dispatch: # Allows this workflow to be triggered by release-please | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref_name }} | |
| cancel-in-progress: true | |
| env: | |
| GHCR_REGISTRY: ghcr.io | |
| GHCR_IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| resolve-version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| semver: ${{ steps.version.outputs.semver }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Resolve release version | |
| id: version | |
| if: ${{ github.ref_name == 'release' }} | |
| run: | | |
| version="$(tr -d '[:space:]' < MANIFOLD_VERSION)" | |
| if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then | |
| echo "::error::release build requires a semver in MANIFOLD_VERSION, got '$version'" | |
| exit 1 | |
| fi | |
| echo "semver=$version" >> "$GITHUB_OUTPUT" | |
| build-api: | |
| needs: resolve-version | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Login GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}-api | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref_name == 'release' }} | |
| type=raw,value=${{ needs.resolve-version.outputs.semver }},enable=${{ github.ref_name == 'release' }} | |
| type=raw,value=preview,enable=${{ github.ref_name == 'main' }} | |
| type=ref,event=branch | |
| type=sha | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker | |
| id: push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./api | |
| target: production | |
| push: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | |
| "RAILS_ENV=production" | |
| build-client: | |
| needs: resolve-version | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Login GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}-client | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref_name == 'release' }} | |
| type=raw,value=${{ needs.resolve-version.outputs.semver }},enable=${{ github.ref_name == 'release' }} | |
| type=raw,value=preview,enable=${{ github.ref_name == 'main' }} | |
| type=ref,event=branch | |
| type=sha | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker | |
| id: push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./client | |
| target: production | |
| push: true | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | |
| "RAILS_ENV=production" |