mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-06-05 22:43:43 +00:00
123 lines
3.3 KiB
YAML
123 lines
3.3 KiB
YAML
name: Go Release
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
go-version:
|
|
description: "Go version to use"
|
|
required: false
|
|
type: string
|
|
default: ">=1.24"
|
|
semver-config:
|
|
description: "Path to semver config file"
|
|
required: false
|
|
type: string
|
|
default: "semver.yaml"
|
|
docker-enabled:
|
|
description: "Enable Docker builds"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
docker-registry:
|
|
description: "Docker registry to push to"
|
|
required: false
|
|
type: string
|
|
default: "ghcr.io"
|
|
rolling-release-tag:
|
|
description: "Create a rolling release tag (e.g., 'v1')"
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
outputs:
|
|
version:
|
|
description: "The calculated version (without v prefix)"
|
|
value: ${{ jobs.version.outputs.version }}
|
|
version_tag:
|
|
description: "The version tag (with v prefix)"
|
|
value: ${{ jobs.version.outputs.version_tag }}
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Run tests
|
|
uses: lukaszraczylo/shared-actions/.github/actions/go-test@main
|
|
with:
|
|
go-version: ${{ inputs.go-version }}
|
|
|
|
version:
|
|
name: Calculate Version
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.semver.outputs.version }}
|
|
version_tag: ${{ steps.semver.outputs.version_tag }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Calculate version
|
|
id: semver
|
|
uses: lukaszraczylo/shared-actions/.github/actions/semver@main
|
|
with:
|
|
config-file: ${{ inputs.semver-config }}
|
|
|
|
release:
|
|
name: Release
|
|
needs: version
|
|
if: needs.version.outputs.version_tag != ''
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
id-token: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ inputs.go-version }}
|
|
|
|
# Docker setup (optional)
|
|
- name: Set up QEMU
|
|
if: inputs.docker-enabled
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
if: inputs.docker-enabled
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GHCR
|
|
if: inputs.docker-enabled
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ inputs.docker-registry }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Run GoReleaser
|
|
uses: lukaszraczylo/shared-actions/.github/actions/goreleaser@main
|
|
with:
|
|
version-tag: ${{ needs.version.outputs.version_tag }}
|
|
mode: full
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
homebrew-tap-token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
|
|
- name: Rolling release
|
|
if: inputs.rolling-release-tag != ''
|
|
uses: lukaszraczylo/shared-actions/.github/actions/rolling-release@main
|
|
with:
|
|
tag: ${{ inputs.rolling-release-tag }}
|
|
version-tag: ${{ needs.version.outputs.version_tag }}
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|