Skip to content

Commit

Permalink
feat: add new version command
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomacf committed Jul 2, 2021
1 parent df51e29 commit 8a5aaf8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
46 changes: 42 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,51 @@ on:
branches:
- main
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup node/npm
uses: actions/setup-node@v2
with:
node-version: 12
- name: install yarn
run: npm install --global yarn
- name: install semantic-release
run: yarn install
- name: semantic release dry run to check next version
run: npx semantic-release --dryRun | tee results
- name: show semanti release results
run: cat results
- name: determine next version
run: cat results | grep -oP 'Published release \K.*? ' >> version
- name: Check next version
run: cat version
- name: upload version file as an artifact
uses: actions/upload-artifact@v2
with:
name: version
path: version
build-linux-amd64:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: download next version artifact
uses: actions/download-artifact@v2
name: version
path: ./
- name: Check next version
run: cat version
- name: setup go
uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
go-version: '^1.16.5'
- name: make release folder
run: mkdir -p .releases/linux-amd64
- name: build
run: GOOS=linux GOARCH=amd64 go build -o .releases/linux-amd64 github.com/nosebit/act
run: GOOS=linux GOARCH=amd64 go build -o .releases/linux-amd64 -ldflags="-X 'github.com/nosebit/act/cmd.BinVersion=v$(cat version)' -X 'github.com/nosebit/act/cmd.BinOS=v$GOOS' -X 'github.com/nosebit/act/cmd.BinArch=v$GOARCH'" github.com/nosebit/act
- name: compress release folder
run: tar czfv .releases/linux-amd64.tar.gz .releases/linux-amd64/
- name: upload release artifact
Expand All @@ -29,14 +61,20 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v2
- name: download next version artifact
uses: actions/download-artifact@v2
name: version
path: ./
- name: Check next version
run: cat version
- name: setup go
uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
go-version: '^1.16.5'
- name: make release folder
run: mkdir -p .releases/darwin-amd64
- name: build
run: GOOS=darwin GOARCH=amd64 go build -o .releases/darwin-amd64 github.com/nosebit/act
run: GOOS=darwin GOARCH=amd64 go build -o .releases/linux-amd64 -ldflags="-X 'github.com/nosebit/act/cmd.BinVersion=v$(cat version)' -X 'github.com/nosebit/act/cmd.BinOS=v$GOOS' -X 'github.com/nosebit/act/cmd.BinArch=v$GOARCH'" github.com/nosebit/act
- name: compress release folder
run: tar czfv .releases/darwin-amd64.tar.gz .releases/darwin-amd64/
- name: upload release artifact
Expand Down
22 changes: 22 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package cmd

import (
"flag"
"fmt"
"os"
"runtime"

"github.com/nosebit/act/run"
)
Expand All @@ -19,6 +21,13 @@ import (
*/
var cmdName string

//############################################################
// Exposed Variables
//############################################################
var BinVersion = "development"
var BinOS = ""
var BinArch = ""

//############################################################
// Exposed Functions
//############################################################
Expand All @@ -30,6 +39,19 @@ func Exec(args []string) {
cmdName = args[0]

switch cmdName {
case "version":
binOS := BinOS
binArch := BinArch

if binOS == "" {
binOS = runtime.GOOS
}

if binArch == "" {
binArch = runtime.GOARCH
}

fmt.Printf("act version %s %s/%s\n", BinVersion, binOS, binArch)
case "run":
run.Exec(args[1:])
case "log":
Expand Down

0 comments on commit 8a5aaf8

Please # to comment.