Skip to content

Commit

Permalink
Use gorelease to publish new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Svetlin Ralchev committed Dec 13, 2019
1 parent e89cc24 commit 0241c6b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Check out code
- name: Check out Code
uses: actions/checkout@v1
- name: Set up Golang
uses: actions/setup-go@v1
Expand Down
67 changes: 10 additions & 57 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,25 @@ name: release

on:
push:
branches:
- "!*"
tags:
- 'v*'
- "v*.*.*"

jobs:
pipeline:
name:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Set up environment
run: echo ::set-env name=VERSION_NUMBER::$(echo ${GITHUB_REF:10})
- name: Check out Code
uses: actions/checkout@v1
- name: Set up Golang
uses: actions/setup-go@v1
with:
go-version: '1.13.x'
- name: Install Golang tools
run: go install github.com/mitchellh/gox
- name: Build release
run: $HOME/go/bin/gox -ldflags "-X main.Version=$VERSION_NUMBER" --output="$GOX_OUTPUT" --osarch="$GOX_OSARCH" github.com/$GITHUB_REPOSITORY/cmd/prana
env:
GOX_OUTPUT: "./build/{{.OS}}/{{.Dir}}_{{.OS}}_{{.Arch}}"
GOX_OSARCH: "linux/amd64 linux/386 darwin/amd64 darwin/386 windows/386 windows/amd64"
- name: Bundle Linux release
run: zip --junk-paths prana-linux-${{ env.VERSION_NUMBER }}.zip ./build/linux/*
- name: Bundle Darwin release
run: zip --junk-paths prana-darwin-${{ env.VERSION_NUMBER }}.zip ./build/darwin/*
- name: Bundle Windows release
run: zip --junk-paths prana-windows-${{ env.VERSION_NUMBER }}.zip ./build/windows/*
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Linux release
id: upload_release_linux
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release Application
uses: goreleaser/goreleaser-action@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./prana-linux-${{ env.VERSION_NUMBER }}.zip
asset_name: prana-linux-${{ env.VERSION_NUMBER }}.zip
asset_content_type: application/zip
- name: Upload Darwin release
id: upload_release_darwin
uses: actions/[email protected]
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./prana-darwin-${{ env.VERSION_NUMBER }}.zip
asset_name: prana-darwin-${{ env.VERSION_NUMBER }}.zip
asset_content_type: application/zip
- name: Upload Windows release
id: upload_release_windows
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./prana-windows-${{ env.VERSION_NUMBER }}.zip
asset_name: prana-windows-${{ env.VERSION_NUMBER }}.zip
asset_content_type: application/zip
GITHUB_TOKEN: ${{ secrets.GORELEASE_GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
before:
hooks:
- go mod download
builds:
- main: ./cmd/prana/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
brews:
- github:
owner: phogolabs
name: homebrew-tap
name: prana
description: Golang Database Management and Code Generation
homepage: https://github.com/phogolabs/prana
test: |
system "#{bin}/prana -v"
5 changes: 4 additions & 1 deletion cmd/prana/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
"github.com/phogolabs/prana/cmd"
)

// version is injected by goreleaser.com
var version string = "unknown"

var flags = []cli.Flag{
&cli.StringFlag{
Name: "log-level",
Expand Down Expand Up @@ -54,7 +57,7 @@ func main() {
HelpName: "prana",
Usage: "Golang Database Manager",
UsageText: "prana [global options]",
Version: "1.0-beta-05",
Version: version,
Writer: os.Stdout,
ErrWriter: os.Stderr,
Flags: flags,
Expand Down

0 comments on commit 0241c6b

Please sign in to comment.