Skip to content

Commit

Permalink
release using go releaser
Browse files Browse the repository at this point in the history
Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
  • Loading branch information
rjshrjndrn committed Feb 11, 2024
1 parent c7449c5 commit 24f7f10
Showing 1 changed file with 32 additions and 79 deletions.
111 changes: 32 additions & 79 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,87 +1,40 @@
name: Build and Release
# .github/workflows/release.yml
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
- 'v*'
- "*"

jobs:
build:
name: Build on Commit
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Check out code
uses: actions/checkout@v2
permissions:
contents: write
# packages: write
# issues: write

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.19.x'

- name: Build
run: |
go build -o templater
./templater
release:
name: Build and Release Binaries
needs: build
jobs:
goreleaser:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [amd64, '386']
include:
- os: ubuntu-latest
platform: linux
- os: windows-latest
platform: windows
- os: macos-latest
platform: darwin

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.19.x' # Specify your Go version here

- name: Build binaries
env:
GOOS: ${{ matrix.platform }}
GOARCH: ${{ matrix.arch }}
run: |
go build -o templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: templater-${{ matrix.platform }}-${{ matrix.arch }}
path: templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}

- name: Create Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

- name: Upload Release Asset
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
asset_name: templater-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
asset_content_type: application/octet-stream
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

0 comments on commit 24f7f10

Please sign in to comment.