Skip to content

Commit

Permalink
Merge pull request 99designs#326 from 99designs/version
Browse files Browse the repository at this point in the history
Add version const
  • Loading branch information
vektah authored Aug 31, 2018
2 parents a10565b + 681006a commit 234e64f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

set -eu

if ! [ $# -eq 1 ] ; then
echo "usage: ./bin/release [version]"
exit 1
fi

VERSION=$1

if ! git diff-index --quiet HEAD -- ; then
echo "uncommited changes on HEAD, aborting"
exit 1
fi

if [[ ${VERSION:0:1} != "v" ]] ; then
echo "version strings must start with v"
exit 1
fi

git fetch origin
git checkout origin/master

cat > graphql/version.go <<EOF
package graphql
const Version = "$VERSION"
EOF

git add .
git commit -m "release $VERSION"
git tag $VERSION
git push origin $VERSION


echo "Now go write some release notes! https://github.com/99designs/gqlgen/releases"
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"os"

"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/internal/gopath"
"github.com/urfave/cli"
)
Expand All @@ -17,6 +18,7 @@ func Execute() {
app.Description = "This is a library for quickly creating strictly typed graphql servers in golang. See https://gqlgen.com/ for a getting started guide."
app.HideVersion = true
app.Flags = genCmd.Flags
app.Version = graphql.Version
app.Before = func(context *cli.Context) error {
pwd, err := os.Getwd()
if err != nil {
Expand All @@ -38,6 +40,7 @@ func Execute() {
app.Commands = []cli.Command{
genCmd,
initCmd,
versionCmd,
}

if err := app.Run(os.Args); err != nil {
Expand Down
16 changes: 16 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cmd

import (
"fmt"

"github.com/99designs/gqlgen/graphql"
"github.com/urfave/cli"
)

var versionCmd = cli.Command{
Name: "version",
Usage: "print the version string",
Action: func(ctx *cli.Context) {
fmt.Println(graphql.Version)
},
}
3 changes: 3 additions & 0 deletions graphql/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package graphql

const Version = "dev"

0 comments on commit 234e64f

Please sign in to comment.