Skip to content

Commit

Permalink
make releases easier (embed version with compile time var)
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Sto committed May 3, 2021
1 parent 09f8abf commit f7230a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@ jobs:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
- name: Set GOPATH
# temporary fix
# see https://github.com/actions/setup-go/issues/14
run: |
echo "##[set-env name=RELEASE_VERSION;]$(echo ${GITHUB_REF:10})"
echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)"
echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin"
shell: bash
- name: Checkout code
uses: actions/checkout@v1
- name: Set up Go
uses: actions/setup-go@v2
with:
path: ./src/github.com/${{ github.repository }}
go-version: 1.15

- uses: actions/checkout@v2

- name: Set version tag
run: |
echo "RELEASE_VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
- name: Build # This would actually build your project, using zip for an example artifact
run: |
GOOS=windows go build -ldflags "-s -w" -o "gosecretsdump_win_${RELEASE_VERSION}.exe"
GOOS=darwin go build -ldflags "-s -w" -o "gosecretsdump_mac_${RELEASE_VERSION}"
GOOS=linux go build -ldflags "-s -w" -o "gosecretsdump_linux_${RELEASE_VERSION}"
GOOS=windows go build -ldflags "-s -w -X main.version=${RELEASE_VERSION}" -o "gosecretsdump_win_${RELEASE_VERSION}.exe"
GOOS=darwin go build -ldflags "-s -w -X main.version=${RELEASE_VERSION}" -o "gosecretsdump_mac_${RELEASE_VERSION}"
GOOS=linux go build -ldflags "-s -w -X main.version=${RELEASE_VERSION}" -o "gosecretsdump_linux_${RELEASE_VERSION}"
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import (
"github.com/C-Sto/gosecretsdump/cmd"
)

const version = "0.3.0"
var version string

func main() {
//const version = "0.3.0"

func main() {
if version == "" {
version = "DEV"
}
//defer profile.Start(profile.ProfilePath("./")).Stop()
//defer profile.Start(profile.MemProfile, profile.ProfilePath("./")).Stop()
//defer profile.Start(profile.BlockProfile, profile.ProfilePath("./")).Stop()
Expand Down

0 comments on commit f7230a2

Please sign in to comment.