mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-23 21:00:44 +00:00
feat(workflow): Use GoReleaser to simplify the release process
This commit is contained in:
64
.github/workflows/release.yml
vendored
64
.github/workflows/release.yml
vendored
@@ -3,72 +3,30 @@ name: Release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- 'v*.*.*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and Release
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.23'
|
||||
go-version: '1.25'
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build for all platforms
|
||||
run: |
|
||||
VERSION=${{ steps.version.outputs.VERSION }}
|
||||
COMMIT=${{ github.sha }}
|
||||
COMMIT_SHORT=${COMMIT:0:10}
|
||||
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
|
||||
LDFLAGS="-s -w -X main.Version=${VERSION} -X main.GitCommit=${COMMIT_SHORT} -X main.BuildTime=${BUILD_TIME}"
|
||||
|
||||
# Linux amd64
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-linux-amd64 ./cmd/drip
|
||||
|
||||
# Linux arm64
|
||||
GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-linux-arm64 ./cmd/drip
|
||||
|
||||
# macOS amd64
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-darwin-amd64 ./cmd/drip
|
||||
|
||||
# macOS arm64
|
||||
GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-darwin-arm64 ./cmd/drip
|
||||
|
||||
# Windows amd64
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-windows-amd64.exe ./cmd/drip
|
||||
|
||||
# Windows arm64
|
||||
GOOS=windows GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o drip-${VERSION}-windows-arm64.exe ./cmd/drip
|
||||
|
||||
- name: Generate checksums
|
||||
run: |
|
||||
sha256sum drip-${{ steps.version.outputs.VERSION }}-* > checksums.txt
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
files: |
|
||||
drip-${{ steps.version.outputs.VERSION }}-linux-amd64
|
||||
drip-${{ steps.version.outputs.VERSION }}-linux-arm64
|
||||
drip-${{ steps.version.outputs.VERSION }}-darwin-amd64
|
||||
drip-${{ steps.version.outputs.VERSION }}-darwin-arm64
|
||||
drip-${{ steps.version.outputs.VERSION }}-windows-amd64.exe
|
||||
drip-${{ steps.version.outputs.VERSION }}-windows-arm64.exe
|
||||
checksums.txt
|
||||
draft: false
|
||||
prerelease: false
|
||||
generate_release_notes: true
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user