Skip to content

Commit

Permalink
Merge pull request #25 from kenriortega/development
Browse files Browse the repository at this point in the history
ci: migrate from custom release to goreleaser
  • Loading branch information
kenriortega authored Oct 26, 2021
2 parents b341e3f + 4403dc5 commit c885ec0
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 49 deletions.
98 changes: 49 additions & 49 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
name: Release Egosystem proxys binaries
# name: Release Egosystem proxys binaries

on:
release:
types: [created]
# on:
# release:
# types: [created]

jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/amd64,windows/amd64,linux/darwin
goos: [linux,windows,darwin]
goarch: [amd64]
steps:
- uses: actions/checkout@v2
# jobs:
# releases-matrix:
# name: Release Go Binary
# runs-on: ubuntu-latest
# strategy:
# matrix:
# # build and publish in parallel: linux/amd64,windows/amd64,linux/darwin
# goos: [linux,windows,darwin]
# goarch: [amd64]
# steps:
# - uses: actions/checkout@v2

- name: Set BUILD_TIME env
run: echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
- name: Set APP_VERSION env
run: echo APP_VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}
# - name: Set BUILD_TIME env
# run: echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
# - name: Set APP_VERSION env
# run: echo APP_VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}

- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
project_path: "./cmd/"
binary_name: "ngonxctl-${{ env.APP_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}"
ldflags: "-s -X github.com/kenriortega/ngonx/cmd/cli.buildTime=${{env.BUILD_TIME}} -X github.com/kenriortega/ngonx/cmd/cli.versionHash=${{github.sha}} -X github.com/kenriortega/ngonx/cmd/cli.version=${{env.APP_VERSION}}"
# - uses: wangyoucao577/[email protected]
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# goos: ${{ matrix.goos }}
# goarch: ${{ matrix.goarch }}
# project_path: "./cmd/"
# binary_name: "ngonxctl-${{ env.APP_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}"
# ldflags: "-s -X github.com/kenriortega/ngonx/cmd/cli.buildTime=${{env.BUILD_TIME}} -X github.com/kenriortega/ngonx/cmd/cli.versionHash=${{github.sha}} -X github.com/kenriortega/ngonx/cmd/cli.version=${{env.APP_VERSION}}"

releases-matrix-arm:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/arm
goos: [linux]
goarch: [arm]
steps:
- uses: actions/checkout@v2
# releases-matrix-arm:
# name: Release Go Binary
# runs-on: ubuntu-latest
# strategy:
# matrix:
# # build and publish in parallel: linux/arm
# goos: [linux]
# goarch: [arm]
# steps:
# - uses: actions/checkout@v2

- name: Set BUILD_TIME env
run: echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
- name: Set APP_VERSION env
run: echo APP_VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}
# - name: Set BUILD_TIME env
# run: echo BUILD_TIME=$(date --iso-8601=seconds) >> ${GITHUB_ENV}
# - name: Set APP_VERSION env
# run: echo APP_VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}

- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
project_path: "./cmd/"
binary_name: "ngonxctl-${{ env.APP_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}"
ldflags: "-s -X github.com/kenriortega/ngonx/cmd/cli.buildTime=${{env.BUILD_TIME}} -X github.com/kenriortega/ngonx/cmd/cli.versionHash=${{github.sha}} -X github.com/kenriortega/ngonx/cmd/cli.version=${{env.APP_VERSION}}"
# - uses: wangyoucao577/[email protected]
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# goos: ${{ matrix.goos }}
# goarch: ${{ matrix.goarch }}
# project_path: "./cmd/"
# binary_name: "ngonxctl-${{ env.APP_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}"
# ldflags: "-s -X github.com/kenriortega/ngonx/cmd/cli.buildTime=${{env.BUILD_TIME}} -X github.com/kenriortega/ngonx/cmd/cli.versionHash=${{github.sha}} -X github.com/kenriortega/ngonx/cmd/cli.version=${{env.APP_VERSION}}"
29 changes: 29 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: goreleaser

on:
release:
types: [created]

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: -f .goreleaser.yml release --rm-dist

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
-
# ID of the build.
# Defaults to the project name.
id: "ngonx"

# Path to project's (sub)directory containing Go code.
# This is the working directory for the Go build command(s).
# Default is `.`.
# dir: go

# Path to main.go file or main package.
# Notice: when used with `gomod.proxy`, this must be a package.
#
# Default is `.`.
main: ./cmd/cli

# Binary name.
# Can be a path (e.g. `bin/app`) to wrap the binary in a directory.
# Default is the name of the project directory.
binary: ngonxctl

# Custom ldflags templates.
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`.
ldflags:
- -s -w -X cli.version={{.Version}} -X cli.versionHash={{.Commit}} -X cli.buildTime={{.Date}}


env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

0 comments on commit c885ec0

Please sign in to comment.