Skip to content

Commit

Permalink
Create releases
Browse files Browse the repository at this point in the history
  • Loading branch information
nning committed Nov 5, 2021
1 parent d5a71b6 commit 396dbc0
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 11 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
on:
push:
branches: '*'
tags: '*'
pull_request:
branches: '*'
tags: '*'
on: [push, pull_request]

jobs:
build:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
push:
tags: 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '^1.16.8'

- run: make release

- uses: actions/upload-artifact@v2
with:
name: list-proton-versions
path: cmd/list-proton-versions/list-proton-versions

- uses: softprops/action-gh-release@v1
with:
files: list-proton-versions-*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cmd/list-proton-versions/list-proton-versions
/cmd/list-proton-versions/list-proton-versions
/list-proton-versions-*
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
SOURCES = $(shell find . -name \*.go)

LIST_BIN_DIR = cmd/list-proton-versions
LIST_BIN = $(LIST_BIN_DIR)/list-proton-versions
LIST_BIN_FILE = list-proton-versions
LIST_BIN = $(LIST_BIN_DIR)/$(LIST_BIN_FILE)

VERSION := $(shell ./build/version.sh)
BUILDTIME := $(shell date -u +"%Y%m%d%H%M%S")

GOLDFLAGS += -X main.Version=$(VERSION)
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
GOFLAGS = -ldflags "$(GOLDFLAGS)"

build: $(LIST_BIN)

$(LIST_BIN): $(SOURCES)
cd $(LIST_BIN_DIR); go build
cd $(LIST_BIN_DIR); go build $(GOFLAGS)

clean:
rm -f $(LIST_BIN)
rm -f $(LIST_BIN) ./list-proton-versions-*

run: $(LIST_BIN)
./$(LIST_BIN)
Expand All @@ -21,3 +29,6 @@ test:

lint:
golint ./...

release: build
cp $(LIST_BIN) $(LIST_BIN_FILE)-$(VERSION)
4 changes: 4 additions & 0 deletions build/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
version=$(git name-rev --tags --name-only $(git rev-parse HEAD))
[ $version = "undefined" ] && version=$(git rev-parse --short HEAD)
echo $version
11 changes: 11 additions & 0 deletions cmd/list-proton-versions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"github.com/nning/list_proton_versions/steam"
)

var Version string
var Buildtime string

func exitOnError(e error) {
if e != nil {
fmt.Fprintln(os.Stderr, e)
Expand All @@ -33,15 +36,23 @@ func main() {
var ignoreCache bool
var jsonOutput bool
var showAppID bool
var showVersion bool
var user string

flag.BoolVar(&all, "a", false, "List both installed and non-installed games")
flag.BoolVar(&ignoreCache, "c", false, "Ignore app ID/name cache")
flag.BoolVar(&jsonOutput, "j", false, "Output JSON (implies -a and -i)")
flag.BoolVar(&showAppID, "i", false, "Show app ID")
flag.BoolVar(&showVersion, "v", false, "Show version")
flag.StringVar(&user, "u", "", "Steam user name (or SteamID3)")
flag.Parse()

if showVersion {
url := "https://github.com/nning/list_proton_versions/tree/" + Version
fmt.Println(Version, Buildtime, url)
return
}

s, err := steam.New(user, ignoreCache)
exitOnError(err)

Expand Down

0 comments on commit 396dbc0

Please sign in to comment.