Skip to content

Add workflow for GHA (#2) #2

Add workflow for GHA (#2)

Add workflow for GHA (#2) #2

Workflow file for this run

name: goreleaser
run-name: "${{ inputs.releaseVersion }}"
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
inputs:
releaseVersion:
type: string
description: Version to release
required: true
permissions:
contents: write
jobs:
build:
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run GoReleaser (build only)
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: build --clean --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Create tag
if: github.event_name == 'workflow_dispatch'
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ github.event.inputs.releaseVersion }}',
sha: context.sha
})
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/tags/${{ github.event.inputs.releaseVersion }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}