Skip to content

release

release #6

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
version:
description: A version in semver format (e.g. 1.2.3)
required: true
jobs:
tag:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Validate version
run: |
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid version format: ${{ inputs.version }}"
exit 1
fi
- name: Tag
id: tag
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
with:
custom_tag: ${{ inputs.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
needs:
- tag
if: needs.tag.result == 'success'
strategy:
matrix:
include:
- { goos: "linux", goarch: "amd64" }
- { goos: "linux", goarch: "arm64" }
- { goos: "darwin", goarch: "amd64" }
- { goos: "darwin", goarch: "arm64" }
- { goos: "windows", goarch: "amd64" }
- { goos: "windows", goarch: "arm64" }
fail-fast: true
name: Go ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
BINARY_NAME="golens"
[ "$GOOS" = "windows" ] && BINARY_NAME="${BINARY_NAME}.exe"
go build -ldflags="-s -w -X 'github.com/vectier/golens/internal/lsp.Version=${{ inputs.version }}'" -o ${BINARY_NAME} .
- name: Packaging
run: |
ARTIFACT="golens-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz"
tar -czf $ARTIFACT golens*
echo "ARTIFACT=$ARTIFACT" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: v${{ inputs.version }}
files: ${{ env.ARTIFACT }}