octomation/go-service

View on GitHub
.github/workflows/cd.dist.yml

Summary

Maintainability
Test Coverage
name: Release delivery

on:
  workflow_call:
    secrets:
      GORELEASER_TOKEN:
        required: true

  workflow_dispatch:
    inputs:
      reason:
        description: The reason for dispatching it manually.
        type: string
        default: manual healthcheck
        required: true

concurrency:
  group: dist
  cancel-in-progress: true

jobs:
  release:
    name: Releasing
    runs-on: ubuntu-latest

    env:
      DOCKER_CLI_EXPERIMENTAL: enabled

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }
      - name: Set up Go environment
        uses: actions/setup-go@v5.0.0
        with:
          go-version: 1.21.x
          check-latest: true

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3.0.0
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3.0.0
      - name: Login to GitHub Packages
        uses: docker/login-action@v3.0.0
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GORELEASER_TOKEN }}

      - name: Publish the release
        uses: goreleaser/goreleaser-action@v5.0.0
        with:
          distribution: goreleaser
          version: latest
          args: release --clean --fail-fast
        env:
          GITHUB_TOKEN: ${{ secrets.GORELEASER_TOKEN }}

  notify:
    name: Notifying
    needs: [ release ]
    runs-on: ubuntu-latest
    if: failure() || success()

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }

      - name: Send notification
        uses: ./.github/actions/notify
        with:
          emoji: 🚀
          channel: ${{ secrets.SLACK_WEBHOOK }}
          success: ${{ ! contains(needs.*.result, 'failure') }}