Skip to content

goreleaser

goreleaser #1

Workflow file for this run

name: goreleaser
on:
workflow_dispatch:
push:
tags: ["v*"]
permissions:
contents: write
id-token: write
packages: write
jobs:
prepare:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
flags: ""
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v1
if: matrix.os == 'ubuntu-latest'
- uses: docker/setup-buildx-action@v3
if: matrix.os == 'ubuntu-latest'
- name: ghcr-login
uses: docker/login-action@v1
if: matrix.os != 'macos-latest'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: stable
- if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
echo "flags=--nightly" >> $GITHUB_ENV
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/[email protected]
if: matrix.os == 'ubuntu-latest'
with:
path: dist/linux
key: linux-${{ env.sha_short }}${{ env.flags }}
- uses: actions/[email protected]
if: matrix.os == 'macos-latest'
with:
path: dist/darwin
key: darwin-${{ env.sha_short }}${{ env.flags }}
- uses: actions/[email protected]
if: matrix.os == 'windows-latest'
with:
path: dist/windows
key: windows-${{ env.sha_short }}${{ env.flags }}
enableCrossOsArchive: true
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser-pro
version: latest
args: release --clean --split ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
release:
runs-on: ubuntu-latest
needs: prepare
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
flags: ""
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v3
- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected]
- name: ghcr-login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v3
with:
go-version: stable
# copy the cashes from prepare
- if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
echo "flags=--nightly" >> $GITHUB_ENV
- shell: bash
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: actions/[email protected]
with:
path: dist/linux
key: linux-${{ env.sha_short }}${{ env.flags }}
- uses: actions/[email protected]
with:
path: dist/darwin
key: darwin-${{ env.sha_short }}${{ env.flags }}
- uses: actions/[email protected]
with:
path: dist/windows
key: windows-${{ env.sha_short }}${{ env.flags }}
enableCrossOsArchive: true
# release
- uses: goreleaser/goreleaser-action@v4
if: steps.cache.outputs.cache-hit != 'true' # do not run if cache hit
with:
distribution: goreleaser-pro
version: latest
args: continue --merge
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}